From 8af38f0d7541982c750aabf83b2b098ae9933a1a Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 26 Jan 2023 14:23:19 -0800 Subject: [PATCH] cli: consistently `use clap::Command`, and avoid unnecessary qualification --- src/cli_util.rs | 16 ++++++++-------- src/commands/mod.rs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cli_util.rs b/src/cli_util.rs index d799fdef6..0edd7f70a 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -275,7 +275,7 @@ impl TracingSubscription { } pub struct CommandHelper { - app: clap::Command, + app: Command, cwd: PathBuf, string_args: Vec, global_args: GlobalArgs, @@ -286,7 +286,7 @@ pub struct CommandHelper { impl CommandHelper { pub fn new( - app: clap::Command, + app: Command, cwd: PathBuf, string_args: Vec, global_args: GlobalArgs, @@ -305,7 +305,7 @@ impl CommandHelper { } } - pub fn app(&self) -> &clap::Command { + pub fn app(&self) -> &Command { &self.app } @@ -1715,7 +1715,7 @@ impl ValueParserFactory for RevisionArg { fn resolve_aliases( config: &config::Config, - app: &clap::Command, + app: &Command, string_args: &[String], ) -> Result, CommandError> { let mut aliases_map = config.get_table("alias")?; @@ -1771,7 +1771,7 @@ fn resolve_aliases( /// Parse args that must be interpreted early, e.g. before printing help. fn handle_early_args( ui: &mut Ui, - app: &clap::Command, + app: &Command, args: &[String], layered_configs: &mut LayeredConfigs, ) -> Result<(), CommandError> { @@ -1793,7 +1793,7 @@ fn handle_early_args( } pub fn expand_args( - app: &clap::Command, + app: &Command, args_os: ArgsOs, config: &config::Config, ) -> Result, CommandError> { @@ -1811,7 +1811,7 @@ pub fn expand_args( pub fn parse_args( ui: &mut Ui, - app: &clap::Command, + app: &Command, tracing_subscription: &TracingSubscription, string_args: &[String], layered_configs: &mut LayeredConfigs, @@ -1886,7 +1886,7 @@ pub fn handle_command_result(ui: &mut Ui, result: Result<(), CommandError>) -> E #[must_use] pub struct CliRunner { tracing_subscription: TracingSubscription, - app: clap::Command, + app: Command, store_factories: Option, dispatch_fn: CliDispatchFn, } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 1fe60dbe5..d5898b917 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -23,7 +23,7 @@ use std::path::PathBuf; use std::{fs, io}; use clap::builder::NonEmptyStringValueParser; -use clap::{ArgGroup, ArgMatches, CommandFactory, FromArgMatches, Subcommand}; +use clap::{ArgGroup, ArgMatches, Command, CommandFactory, FromArgMatches, Subcommand}; use config::Source; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; @@ -3195,8 +3195,8 @@ fn cmd_sparse(ui: &mut Ui, command: &CommandHelper, args: &SparseArgs) -> Result Ok(()) } -pub fn default_app() -> clap::Command { - let app: clap::Command = Commands::augment_subcommands(Args::command()); +pub fn default_app() -> Command { + let app: Command = Commands::augment_subcommands(Args::command()); app.arg_required_else_help(true).subcommand_required(true) }