-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to clap_derive so CLI arguments are typed
* Renames `clap.rs` to `cli.rs` because otherwise there's confusion between the `clap` crate and local module. * `Cli` struct added that almost identically represents the current state of the CLI with no logical changes. --- ## `--help` Comparison Before: https://gist.github.com/AndreasBackx/5945b366e989159f4669e7ba30c13239 After: https://gist.github.com/AndreasBackx/8929c8bde080eac0cafd33128210b0cc Diff (ignoring whitespace changes due to table alignment): ```diff 1c1 < Screenshot tool for compositors implementing zwlr_screencopy_v1. --- > Screenshot tool for wlroots based compositors implementing the zwlr_screencopy_v1 protocol. 9d8 < -c, --cursor Enable cursor in screenshots 10a10 > -c, --cursor Enable cursor in screenshots 12c12 < -l, --listoutputs List all valid outputs --- > -l, --list-outputs List all valid outputs 14c14 < --chooseoutput Present a fuzzy selector for outputs --- > --choose-output Present a fuzzy selector for outputs 16a17 > ``` You can see that the only changes are: - About is longer, this is now using the value from Cargo.toml instead of a duplicate text that was shorter. - Some have a dash where the English words would have a space, e.g: "list-outputs" instead of "listoutputs". I've also made the old still work via an alias: https://gist.github.com/AndreasBackx/6025e91844e3d766d4264a01ae4d1a71 This seems like a tiny improvement? I plan to make further changes later, but I want to keep PRs separate.
- Loading branch information
1 parent
a023ff1
commit 87be331
Showing
5 changed files
with
85 additions
and
98 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use clap::arg; | ||
|
||
use clap::Parser; | ||
|
||
#[derive(Parser)] | ||
#[command(version, about)] | ||
pub struct Cli { | ||
/// Enable debug mode | ||
#[arg(short, long, action = clap::ArgAction::SetTrue)] | ||
pub debug: bool, | ||
|
||
/// Arguments to call slurp with for selecting a region | ||
#[arg(short, long, value_name = "SLURP_ARGS")] | ||
pub slurp: Option<String>, | ||
|
||
/// Mention a custom file path | ||
#[arg(short, long, conflicts_with = "stdout", value_name = "FILE_PATH")] | ||
pub file: Option<String>, | ||
|
||
/// Output the image data to standard out | ||
#[arg(long, conflicts_with = "file", action = clap::ArgAction::SetTrue)] | ||
pub stdout: bool, | ||
|
||
/// Enable cursor in screenshots | ||
#[arg(short, long, action = clap::ArgAction::SetTrue)] | ||
pub cursor: bool, | ||
|
||
/// Set image encoder (Png is default) | ||
#[arg(short, long, value_name = "FILE_EXTENSION")] | ||
pub extension: Option<String>, | ||
|
||
/// List all valid outputs | ||
#[arg(short, long, alias = "listoutputs", action = clap::ArgAction::SetTrue)] | ||
pub list_outputs: bool, | ||
|
||
/// Choose a particular display to screenshot | ||
#[arg(short, long, conflicts_with = "slurp")] | ||
pub output: Option<String>, | ||
|
||
/// Present a fuzzy selector for outputs | ||
#[arg(long, alias = "chooseoutput", conflicts_with_all = ["slurp", "output"], action = clap::ArgAction::SetTrue)] | ||
pub choose_output: bool, | ||
} |
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