Skip to content
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

fix(dre): adding back output of proposals #798

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Changes from 2 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
78 changes: 46 additions & 32 deletions rs/cli/src/ic_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl UpdateVersion {
[
[
vec![
format!("--{}-version-to-elect", self.release_artifact),
"--replica-version-to-elect".to_string(),
self.version.to_string(),
"--release-package-sha256-hex".to_string(),
self.stringified_hash.to_string(),
Expand All @@ -52,7 +52,7 @@ impl UpdateVersion {
]
.concat(),
match self.versions_to_retire.clone() {
Some(versions) => [vec![format!("--{}-versions-to-unelect", &self.release_artifact)], versions].concat(),
Some(versions) => vec![vec!["--replica-versions-to-unelect".to_string()], versions].concat(),
None => vec![],
},
]
Expand Down Expand Up @@ -112,7 +112,14 @@ impl IcAdminWrapper {
);
}

async fn _exec(&self, cmd: ProposeCommand, opts: ProposeOptions, as_simulation: bool, print_out_command: bool) -> anyhow::Result<String> {
async fn _exec(
&self,
cmd: ProposeCommand,
opts: ProposeOptions,
as_simulation: bool,
print_out_command: bool,
print_ic_admin_out: bool,
) -> anyhow::Result<String> {
if let Some(summary) = opts.clone().summary {
let summary_count = summary.chars().count();
if summary_count > MAX_SUMMARY_CHAR_COUNT {
Expand All @@ -124,32 +131,39 @@ impl IcAdminWrapper {
}
}

self.run(
&cmd.get_command_name(),
[
// Make sure there is no more than one `--dry-run` argument, or else ic-admin will complain.
if as_simulation && !cmd.args().contains(&String::from("--dry-run")) {
vec!["--dry-run".to_string()]
} else {
Default::default()
},
opts.title.map(|t| vec!["--proposal-title".to_string(), t]).unwrap_or_default(),
opts.summary
.map(|s| {
vec![
"--summary".to_string(),
format!("{}{}", s, opts.motivation.map(|m| format!("\n\nMotivation: {m}")).unwrap_or_default(),),
]
})
.unwrap_or_default(),
cmd.args(),
self.neuron.proposer_as_arg_vec(),
]
.concat()
.as_slice(),
print_out_command,
)
.await
let cmd_out = self
.run(
&cmd.get_command_name(),
[
// Make sure there is no more than one `--dry-run` argument, or else ic-admin will complain.
if as_simulation && !cmd.args().contains(&String::from("--dry-run")) {
vec!["--dry-run".to_string()]
} else {
Default::default()
},
opts.title.map(|t| vec!["--proposal-title".to_string(), t]).unwrap_or_default(),
opts.summary
.map(|s| {
vec![
"--summary".to_string(),
format!("{}{}", s, opts.motivation.map(|m| format!("\n\nMotivation: {m}")).unwrap_or_default(),),
]
})
.unwrap_or_default(),
cmd.args(),
self.neuron.proposer_as_arg_vec(),
]
.concat()
.as_slice(),
print_out_command,
)
.await?;

if print_ic_admin_out {
println!("{}", cmd_out)
}

Ok(cmd_out)
}

pub async fn propose_run(&self, cmd: ProposeCommand, opts: ProposeOptions) -> anyhow::Result<String> {
Expand All @@ -159,18 +173,18 @@ impl IcAdminWrapper {
async fn propose_run_inner(&self, cmd: ProposeCommand, opts: ProposeOptions, dry_run: bool) -> anyhow::Result<String> {
// Dry run, or --help executions run immediately and do not proceed.
if dry_run || cmd.args().contains(&String::from("--help")) || cmd.args().contains(&String::from("--dry-run")) {
return self._exec(cmd, opts, true, false).await;
return self._exec(cmd, opts, true, false, false).await;
}

// If --yes was specified, don't ask the user if they want to proceed
if !self.proceed_without_confirmation {
self._exec(cmd.clone(), opts.clone(), true, false).await?;
self._exec(cmd.clone(), opts.clone(), true, false, true).await?;
}

if self.proceed_without_confirmation || Confirm::new().with_prompt("Do you want to continue?").default(false).interact()? {
// User confirmed the desire to submit the proposal and no obvious problems were
// found. Proceeding!
self._exec(cmd, opts, false, true).await
self._exec(cmd, opts, false, true, true).await
} else {
Err(anyhow::anyhow!("Action aborted"))
}
Expand Down
Loading