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: Improved usability of NEAR CLI in scripts #445

Merged
merged 43 commits into from
Mar 12, 2025
Merged

Conversation

FroVolod
Copy link
Collaborator

@FroVolod FroVolod commented Feb 4, 2025

Resolves #437

Running NEAR CLI in the --quiet case:
Image

Running NEAR CLI in the "interactive" case:
Screenshot 2025-02-04 at 19 16 42
Screenshot 2025-02-04 at 19 17 18

@FroVolod FroVolod force-pushed the update-for-quiet-option branch from 145b7a9 to 65180f7 Compare February 24, 2025 15:51
@FroVolod FroVolod marked this pull request as ready for review March 5, 2025 07:40
akorchyn
akorchyn previously approved these changes Mar 6, 2025
Copy link
Collaborator

@akorchyn akorchyn left a 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.

@@ -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(),
Copy link
Collaborator

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------------------------------------");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/common.rs Outdated
Comment on lines 1340 to 1343
if let crate::Verbosity::Quiet = verbosity {
std::io::stdout().write_all(bytes_result)?;
return Ok(());
};
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@race-of-sloths score 13

@race-of-sloths
Copy link

race-of-sloths commented Mar 12, 2025

@FroVolod Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Weekly streak is on the road, smart strategy! Secure your streak with another PR!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@frol 13

Your contribution is much appreciated with a final score of 13!
You have received 147 (130 base + 10 monthly bonus + 5% lifetime bonus) Sloth points for this contribution

@frol received 25 Sloth Points for reviewing and scoring this pull request.

Congratulations @FroVolod! Your PR was highly scored and you completed another monthly streak! To keep your monthly streak make another pull request next month and get 8+ score for it

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@frol frol merged commit 5e11474 into main Mar 12, 2025
11 checks passed
@frol frol deleted the update-for-quiet-option branch March 12, 2025 20:34
@frol frol mentioned this pull request Mar 12, 2025
akorchyn pushed a commit that referenced this pull request Mar 13, 2025
## 🤖 New release

* `near-cli-rs`: 0.18.0 -> 0.19.0 (⚠ API breaking changes)

### ⚠ `near-cli-rs` breaking changes

```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field GlobalContext.verbosity in /tmp/.tmpqoEbVp/near-cli-rs/src/lib.rs:19

--- failure function_missing: pub fn removed or renamed ---

Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/function_missing.ron

Failed in:
  function near_cli_rs::common::create_used_account_list_from_keychain, previously in file /tmp/.tmpzjZyQv/near-cli-rs/src/common.rs:2604

--- failure function_parameter_count_changed: pub fn parameter count changed ---

Description:
A publicly-visible function now takes a different number of parameters.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/function_parameter_count_changed.ron

Failed in:
  near_cli_rs::common::print_transaction_status now takes 3 parameters instead of 2, in /tmp/.tmpqoEbVp/near-cli-rs/src/common.rs:1323

--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_pub_field_missing.ron

Failed in:
  field teach_me of struct GlobalContext, previously in file /tmp/.tmpzjZyQv/near-cli-rs/src/lib.rs:19
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.19.0](v0.18.0...v0.19.0)
- 2025-03-12

### Added

- Improved usability of NEAR CLI in scripts
([#445](#445))
- Added "send all" option to fungible tokens
([#440](#440))
- let users specify a memo when sending ft
- A new `--quiet` flag to suppress noisy output in scripting scenarios
([#441](#441))

### Fixed

- Fixed information about successful transfer of "send all" ft tokens
([#447](#447))
- Fixed cli command for memo parameter
([#446](#446))
- Use legacy keychain as a fallback storage when system keychain is not
supported (e.g. WSL, Codespaces, Docker containers, CI)
([#439](#439))

### Other

- [**breaking**] updates near-* dependencies to 0.29 release
([#455](#455))
- Typos fix ([#451](#451))
- Added the ability to add an account ID to the account list without
using the legacy keychain
([#449](#449))
- Updated the copyright year to 2025
([#448](#448))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Shipped 🚀
Development

Successfully merging this pull request may close these issues.

Usability of the NEAR CLI in scripting?
5 participants