-
Notifications
You must be signed in to change notification settings - Fork 65
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: Improved usability of NEAR CLI in scripts #445
base: main
Are you sure you want to change the base?
Conversation
.with(env_filter) | ||
.init(); | ||
} | ||
Verbosity::Quiet => {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that's a good use of the tracing
crate 👍
145b7a9
to
65180f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big effort. But I think it can be improved and reduce repeat-ness.
I think it would be beneficial to introduce targets.
e.g.: teach-me, interactive, output.
And depending on the parameter, suppress interactive.
src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs
Show resolved
Hide resolved
@@ -138,6 +145,10 @@ fn save_access_key( | |||
account_id.as_ref(), | |||
) | |||
.wrap_err_with(|| format!("Failed to save a file with access key: {}", public_key_str))?; | |||
eprintln!("{}", storage_message); | |||
tracing::info!( | |||
parent: &tracing::Span::none(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to repeat that parent: none()?
if let crate::Verbosity::Quiet = verbosity { | ||
println!("{}", info_str); | ||
}; | ||
info_str.push_str("\n------------------------------------"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
println!("Contract state (values):\n{}\n", serde_json::to_string_pretty(&result.values)?); | ||
println!("Contract state (proof):\n{:#?}\n", result.proof) | ||
} | ||
tracing::info!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else?
To be honest, I believe that tracing could be configured with using target to display output
and to remove noise
this will help to reduce that repeateness. I would ask you to take a look a bit into that direction.
I don't mind if it will come in the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
src/common.rs
Outdated
if let crate::Verbosity::Quiet = verbosity { | ||
std::io::stdout().write_all(bytes_result)?; | ||
return Ok(()); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this block before let result_output
, so the program does not perform useless work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Resolves #437
Running NEAR CLI in the --quiet case:

Running NEAR CLI in the "interactive" case:

