Skip to content

Commit cff9d75

Browse files
authored
feat: A new --quiet flag to suppress noisy output in scripting scenarios (#441)
Improves #437
1 parent 1ec213c commit cff9d75

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

src/commands/transaction/reconstruct_transaction/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,15 @@ impl TransactionInfoContext {
112112
cmd_cli_args.extend(skip_action.to_cli_args());
113113

114114
let near_cli_exec_path = crate::common::get_near_exec_path();
115-
eprintln!("Here is your console command to run archive transaction. You can to edit it or re-run:");
116-
eprintln!(
117-
"{}\n",
118-
shell_words::join(std::iter::once(near_cli_exec_path).chain(cmd_cli_args))
119-
);
115+
if !previous_context.quiet {
116+
eprintln!("Here is your console command to run archive transaction. You can to edit it or re-run:");
117+
eprintln!(
118+
"{}\n",
119+
shell_words::join(
120+
std::iter::once(near_cli_exec_path).chain(cmd_cli_args)
121+
)
122+
);
123+
}
120124
Ok(())
121125
}
122126
});

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod utils_command;
1616
pub struct GlobalContext {
1717
pub config: crate::config::Config,
1818
pub offline: bool,
19+
pub quiet: bool,
1920
pub teach_me: bool,
2021
}
2122

src/main.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct Cmd {
3131
/// Offline mode
3232
#[interactive_clap(long)]
3333
offline: bool,
34+
/// Quiet mode
35+
#[interactive_clap(long)]
36+
quiet: bool,
3437
/// TEACH-ME mode
3538
#[interactive_clap(long)]
3639
teach_me: bool,
@@ -49,6 +52,7 @@ impl CmdContext {
4952
Ok(Self(crate::GlobalContext {
5053
config: previous_context.0,
5154
offline: scope.offline,
55+
quiet: scope.quiet,
5256
teach_me: scope.teach_me,
5357
}))
5458
}
@@ -123,10 +127,12 @@ fn main() -> crate::common::CliResult {
123127
std::iter::once(&near_cli_exec_path).chain(&cli_cmd.to_cli_args()),
124128
);
125129

126-
eprintln!(
127-
"\n\nHere is your console command if you need to script it or re-run:\n {}\n",
128-
cli_cmd_str.yellow()
129-
);
130+
if !cli_cmd.quiet {
131+
eprintln!(
132+
"\n\nHere is your console command if you need to script it or re-run:\n {}\n",
133+
cli_cmd_str.yellow()
134+
);
135+
}
130136

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

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

148-
eprintln!(
149-
"\nHere is your console command if you need to script it or re-run:\n {}\n",
150-
cli_cmd_str.yellow()
151-
);
154+
if !cli_cmd.quiet {
155+
eprintln!(
156+
"\nHere is your console command if you need to script it or re-run:\n {}\n",
157+
cli_cmd_str.yellow()
158+
);
159+
}
152160

153161
crate::common::save_cli_command(&cli_cmd_str);
154162
}
@@ -186,6 +194,7 @@ fn main() -> crate::common::CliResult {
186194
);
187195
let self_update_cli_cmd = CliCmd {
188196
offline: false,
197+
quiet: false,
189198
teach_me: false,
190199
top_level:
191200
Some(crate::commands::CliTopLevelCommand::Extensions(

0 commit comments

Comments
 (0)