Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/add-global-flag-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"cli": minor
"cli-js": minor
---

Added a new `global` boolean flag to the `CliArg` struct to support global CLI arguments. This flag allows arguments like `--verbose` to be marked as global and automatically propagated to all subcommands, enabling consistent availability throughout the CLI.

The new field is optional and defaults to false.
6 changes: 6 additions & 0 deletions plugins/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ pub struct Arg {
/// It does not define position in the argument list as a whole. When utilized with multiple=true,
/// only the last positional argument may be defined as multiple (i.e. the one with the highest index).
pub index: Option<usize>,
/// Specifies whether the argument should be global.
///
/// Global arguments are propagated to all subcommands automatically,
/// making them available throughout the CLI regardless of where they are defined.
#[serde(default)]
pub global: bool,
}

/// describes a CLI configuration
Expand Down
2 changes: 2 additions & 0 deletions plugins/cli/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,7 @@ fn get_arg(arg_name: String, arg: &Arg) -> ClapArg {
clap_arg = bind_value_arg!(arg, clap_arg, require_equals);
clap_arg = bind_value_arg!(arg, clap_arg, index);

clap_arg = clap_arg.global(arg.global);

clap_arg
}
Loading