Skip to content

Commit

Permalink
feat: Added a --quiet flag to suppress noisy output (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Jan 27, 2025
1 parent 4287b2e commit 4754c8f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
14 changes: 9 additions & 5 deletions src/commands/transaction/reconstruct_transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ impl TransactionInfoContext {
cmd_cli_args.extend(skip_action.to_cli_args());

let near_cli_exec_path = crate::common::get_near_exec_path();
eprintln!("Here is your console command to run archive transaction. You can to edit it or re-run:");
eprintln!(
"{}\n",
shell_words::join(std::iter::once(near_cli_exec_path).chain(cmd_cli_args))
);
if !previous_context.quiet {
eprintln!("Here is your console command to run archive transaction. You can to edit it or re-run:");
eprintln!(
"{}\n",
shell_words::join(
std::iter::once(near_cli_exec_path).chain(cmd_cli_args)
)
);
}
Ok(())
}
});
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod utils_command;
pub struct GlobalContext {
pub config: crate::config::Config,
pub offline: bool,
pub quiet: bool,
pub teach_me: bool,
}

Expand Down
25 changes: 17 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ struct Cmd {
/// Offline mode
#[interactive_clap(long)]
offline: bool,
/// Quiet mode
#[interactive_clap(long)]
quiet: bool,
/// TEACH-ME mode
#[interactive_clap(long)]
teach_me: bool,
Expand All @@ -49,6 +52,7 @@ impl CmdContext {
Ok(Self(crate::GlobalContext {
config: previous_context.0,
offline: scope.offline,
quiet: scope.quiet,
teach_me: scope.teach_me,
}))
}
Expand Down Expand Up @@ -123,10 +127,12 @@ fn main() -> crate::common::CliResult {
std::iter::once(&near_cli_exec_path).chain(&cli_cmd.to_cli_args()),
);

eprintln!(
"\n\nHere is your console command if you need to script it or re-run:\n {}\n",
cli_cmd_str.yellow()
);
if !cli_cmd.quiet {
eprintln!(
"\n\nHere is your console command if you need to script it or re-run:\n {}\n",
cli_cmd_str.yellow()
);
}

crate::common::save_cli_command(&cli_cmd_str);

Expand All @@ -145,10 +151,12 @@ fn main() -> crate::common::CliResult {
std::iter::once(&near_cli_exec_path).chain(&cli_cmd.to_cli_args()),
);

eprintln!(
"\nHere is your console command if you need to script it or re-run:\n {}\n",
cli_cmd_str.yellow()
);
if !cli_cmd.quiet {
eprintln!(
"\nHere is your console command if you need to script it or re-run:\n {}\n",
cli_cmd_str.yellow()
);
}

crate::common::save_cli_command(&cli_cmd_str);
}
Expand Down Expand Up @@ -186,6 +194,7 @@ fn main() -> crate::common::CliResult {
);
let self_update_cli_cmd = CliCmd {
offline: false,
quiet: false,
teach_me: false,
top_level:
Some(crate::commands::CliTopLevelCommand::Extensions(
Expand Down

0 comments on commit 4754c8f

Please sign in to comment.