Skip to content

Commit

Permalink
cli: make "--verbose" a global flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Jan 3, 2024
1 parent 0d42097 commit 021e1c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn clap() -> clap::Command {
.help("be verbose (e.g., show command lines)")
.short('v')
.long("verbose")
.global(true)
.action(ArgAction::Count)
}

Expand Down Expand Up @@ -101,13 +102,13 @@ pub fn clap() -> clap::Command {
.env("LAZE_GLOBAL")
.action(ArgAction::SetTrue),
)
.arg(verbose())
.subcommand(
Command::new("build")
.about("generate build files and build")
.allow_external_subcommands(true)
.override_usage("laze build [OPTIONS] [<TASK> [ARGS]...]")
.next_help_heading("Build options")
.arg(verbose())
.arg(build_dir())
.arg(
Arg::new("generate-only")
Expand Down Expand Up @@ -154,7 +155,6 @@ pub fn clap() -> clap::Command {
Command::new("clean")
.about("clean current configuration")
.arg(build_dir())
.arg(verbose())
.arg(
Arg::new("unused")
.short('u')
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ fn try_main() -> Result<i32> {
let global = matches.get_flag("global");
env::set_current_dir(&project_root).context(format!("cannot change to \"{project_root}\""))?;

let verbose = matches.get_count("verbose");

match matches.subcommand() {
Some(("build", build_matches)) => {
let verbose = build_matches.get_count("verbose");
let build_dir = build_matches.get_one::<Utf8PathBuf>("build-dir").unwrap();

// collect builder names from args
Expand Down Expand Up @@ -350,7 +351,6 @@ fn try_main() -> Result<i32> {
}
}
Some(("clean", clean_matches)) => {
let verbose = clean_matches.get_count("verbose");
let unused = clean_matches.get_flag("unused");
let build_dir = clean_matches.get_one::<Utf8PathBuf>("build-dir").unwrap();
let mode = match global {
Expand Down

0 comments on commit 021e1c7

Please sign in to comment.