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

feat: A new --quiet flag to suppress noisy output in scripting scenarios #441

Merged
merged 1 commit into from
Jan 27, 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
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
Loading