mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-11-22 16:06:38 +00:00
Input validation
This commit is contained in:
parent
87175b6619
commit
e07d5bfb3e
@ -5,7 +5,7 @@ edition = "2021"
|
|||||||
description = "Wipe the content of your terminal."
|
description = "Wipe the content of your terminal."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/ricoriedel/wipe"
|
repository = "https://github.com/ricoriedel/wipe"
|
||||||
authors = ["Rico Riedel"]
|
authors = ["Rico Riedel <rico.riedel@protonmail.ch>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "3.2", features = ["derive"] }
|
clap = { version = "3.2", features = ["derive"] }
|
||||||
|
29
src/main.rs
29
src/main.rs
@ -19,7 +19,8 @@ pub use vec::*;
|
|||||||
use crate::convert::*;
|
use crate::convert::*;
|
||||||
use crate::pattern::*;
|
use crate::pattern::*;
|
||||||
use crate::transform::*;
|
use crate::transform::*;
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::builder::NonEmptyStringValueParser;
|
||||||
|
use clap::{value_parser, Parser, ValueEnum};
|
||||||
use crossterm::style::Color;
|
use crossterm::style::Color;
|
||||||
use crossterm::style::Color::*;
|
use crossterm::style::Color::*;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
@ -33,29 +34,29 @@ use std::time::Duration;
|
|||||||
about = env!("CARGO_PKG_DESCRIPTION"),
|
about = env!("CARGO_PKG_DESCRIPTION"),
|
||||||
)]
|
)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Set the duration of the animation [milliseconds]
|
/// Set the animation duration [milliseconds]
|
||||||
#[clap(long, default_value_t = 2000)]
|
#[clap(long, default_value_t = 2000, value_parser = value_parser!(u64).range(0..=60_000))]
|
||||||
duration: u64,
|
duration: u64,
|
||||||
/// Set the frames per second
|
/// Set the frames per second
|
||||||
#[clap(long, default_value_t = 60)]
|
#[clap(long, default_value_t = 60, value_parser = value_parser!(u64).range(1..=480))]
|
||||||
fps: u64,
|
fps: u64,
|
||||||
/// Set the chars used to model the pattern
|
/// Set the chars used to model the pattern
|
||||||
#[clap(long, default_value = ".:+#")]
|
#[clap(long, default_value = ".:+#", value_parser = NonEmptyStringValueParser::new())]
|
||||||
chars: String,
|
chars: String,
|
||||||
/// Set the pattern
|
/// Set the pattern
|
||||||
#[clap(long, value_enum)]
|
#[clap(long, value_enum)]
|
||||||
char_pattern: Option<PatternEnum>,
|
char_pattern: Option<PatternEnum>,
|
||||||
/// Revert the pattern [possible values: true, false]
|
/// Invert the pattern
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
char_invert: Option<bool>,
|
char_invert: Option<bool>,
|
||||||
/// Swap the x-axis and y-axis of the pattern
|
/// Swap the x-axis and y-axis of the pattern
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
char_swap: Option<bool>,
|
char_swap: Option<bool>,
|
||||||
/// Set the count of segments of the pattern [default: 1-4]
|
/// Set the segment count of the pattern [default: 1-4]
|
||||||
#[clap(long)]
|
#[clap(long, value_parser = value_parser!(u8).range(1..255))]
|
||||||
char_segments: Option<u8>,
|
char_segments: Option<u8>,
|
||||||
/// Set the count of slices of the pattern [default: 1-4]
|
/// Set the slice count of the pattern [default: 1-4]
|
||||||
#[clap(long)]
|
#[clap(long, value_parser = value_parser!(u8).range(1..255))]
|
||||||
char_slices: Option<u8>,
|
char_slices: Option<u8>,
|
||||||
/// Set the colors used to fill the pattern
|
/// Set the colors used to fill the pattern
|
||||||
#[clap(long, value_enum)]
|
#[clap(long, value_enum)]
|
||||||
@ -63,17 +64,17 @@ struct Args {
|
|||||||
/// Set the fill pattern
|
/// Set the fill pattern
|
||||||
#[clap(long, value_enum)]
|
#[clap(long, value_enum)]
|
||||||
color_pattern: Option<PatternEnum>,
|
color_pattern: Option<PatternEnum>,
|
||||||
/// Choose if the fill pattern should move [possible values: true, false]
|
/// Choose if the fill pattern should move
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
color_shift: Option<bool>,
|
color_shift: Option<bool>,
|
||||||
/// Revert the fill pattern
|
/// Invert the fill pattern
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
color_invert: Option<bool>,
|
color_invert: Option<bool>,
|
||||||
/// Swap the x-axis and y-axis of the fill pattern
|
/// Swap the x-axis and y-axis of the fill pattern
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
color_swap: Option<bool>,
|
color_swap: Option<bool>,
|
||||||
/// Set the count of slices of the fill pattern [default: 1-4]
|
/// Set the slice count of the fill pattern [default: 1-4]
|
||||||
#[clap(long)]
|
#[clap(long, value_parser = value_parser!(u8).range(1..255))]
|
||||||
color_slices: Option<u8>,
|
color_slices: Option<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user