8000 feat(cli): refine '--help' handling in propose command by sasa-tomic · Pull Request #1363 · dfinity/dre · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(cli): refine '--help' handling in propose command #1363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
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
13 changes: 11 additions & 2 deletions rs/cli/src/commands/propose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use crate::{
};

#[derive(Args, Debug)]
/// Disables automatic help flag parsing so that "--help" can be handled manually to display propose subcommands.
#[clap(disable_help_flag = true)]
pub struct Propose {
#[clap(flatten)]
pub submission_parameters: SubmissionParameters,
Expand Down Expand Up @@ -37,13 +39,20 @@ impl ExecutableCommand for Propose {
args.to_vec()
};

if args.is_empty() {
if args.is_empty() || args.len() == 1 && args[0] == "--help" {
return ctx.help_propose(None).await;
}

let cmd = IcAdminProposal::new(IcAdminProposalCommand::Raw(args.clone()), Default::default());

Submitter::from(&self.submission_parameters)
// If the '--help' flag is present, switch to dry-run mode.
// This automatically bypasses interactive prompts, as they are unnecessary and unexpected when displaying help.
let mut submission_params = self.submission_parameters.clone();
if args.contains(&String::from("--help")) {
submission_params.confirmation_mode.dry_run = true;
}

Submitter::from(&submission_params)
.propose_and_print(ctx.ic_admin_executor().await?.execution(cmd), ForumPostKind::Generic)
.await
}
Expand Down
2 changes: 1 addition & 1 deletion rs/cli/src/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct ConfirmationModeOptions {
yes: bool,

#[clap(long, aliases = [ "dry-run", "dryrun", "simulate", "no"], env = "DRY_RUN", global = true, conflicts_with = "yes", help = r#"Dry-run, or simulate operation. If specified will not make any changes; instead, it will show what would be done or submitted."#,help_heading = "Options on how to proceed")]
dry_run: bool,
pub(crate) dry_run: bool,
}

#[cfg(test)]
Expand Down
0