-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to clap 3, create error macro, solve clippy lints
and more
- Loading branch information
1 parent
fc6302d
commit d3a9418
Showing
7 changed files
with
244 additions
and
141 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,31 @@ | ||
use clap::*; | ||
use clap::Parser; | ||
use std::ffi::OsString; | ||
|
||
pub(crate) fn parse_args() -> clap::ArgMatches<'static> { | ||
App::new(crate_name!()) | ||
.version(crate_version!()) | ||
.about(crate_description!()) | ||
.help_message("Display help information.") | ||
.after_help("Please, contribute and leave issues at https://github.com/marcospb19/dawctl") | ||
.version_message("Display version information.") | ||
.settings(&[AppSettings::ColoredHelp]) | ||
.arg( | ||
Arg::with_name("dpi") | ||
.long("--dpi") | ||
.short("-d") | ||
.value_name("DPI") | ||
.help("Sensor DPI, multiples of 100. [200-6400]"), | ||
) | ||
.arg( | ||
Arg::with_name("path") | ||
.long("--path") | ||
.short("-p") | ||
.value_name("PATH") | ||
.help("Path to the hidraw node. (example: /dev/hidraw3)"), | ||
) | ||
.arg( | ||
Arg::with_name("brightness") | ||
.long("--light") | ||
.short("-l") | ||
.value_name("BRIGHTNESS_LEVEL") | ||
.help("Brightness level of the wheel and logo. [0-100]"), | ||
) | ||
.arg( | ||
Arg::with_name("frequency") | ||
.long("--frequency") | ||
.short("-f") | ||
.value_name("FREQUENCY") | ||
.help("Sensor frequency in Hz. [500 or 1000]") | ||
.possible_values(&["500", "1000"]) | ||
.hide_possible_values(true), | ||
) | ||
.arg( | ||
Arg::with_name("breath") | ||
.long("--breath") | ||
.short("-b") | ||
.help("Lighting breath effect."), | ||
) | ||
.get_matches() | ||
impl Args { | ||
pub fn argparse() -> Self { | ||
Self::parse() | ||
} | ||
} | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
/// Sensor DPI, multiples of 100. [200-6400]. | ||
#[clap(short, long, value_name = "DPI")] | ||
pub dpi: Option<u16>, | ||
|
||
/// Brightness level of the wheel and logo. [0-100] | ||
#[clap(short = 'l', long = "--light", value_name = "BRIGHTNESS_LEVEL")] | ||
pub brightness: Option<u16>, | ||
|
||
/// Sensor frequency in Hz. [500 or 1000] | ||
#[clap(short, long, value_name = "FREQUENCY", possible_values = &["500", "1000"], hide_possible_values = true)] | ||
pub frequency: Option<u16>, | ||
|
||
/// Lighting breath effect. | ||
#[clap(short, long)] | ||
pub breath: bool, | ||
|
||
/// Path to the hidraw node. (example: /dev/hidraw3). | ||
#[clap(short, long, value_name = "PATH")] | ||
pub path: Option<OsString>, | ||
} |
Oops, something went wrong.