fix(cdk-cli): parse --unit consistently and scope balance by currency#1876
Closed
b-l-u-e wants to merge 1 commit intocashubtc:mainfrom
Closed
fix(cdk-cli): parse --unit consistently and scope balance by currency#1876b-l-u-e wants to merge 1 commit intocashubtc:mainfrom
b-l-u-e wants to merge 1 commit intocashubtc:mainfrom
Conversation
Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
55e0a11 to
609da8b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1876 +/- ##
==========================================
- Coverage 63.59% 63.55% -0.05%
==========================================
Files 329 329
Lines 54881 54881
==========================================
- Hits 34904 34878 -26
- Misses 19977 20003 +26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lescuer97
reviewed
Apr 14, 2026
| /// `--unit usd` for USD-only wallets). | ||
| pub async fn balance( | ||
| wallet_repository: &WalletRepository, | ||
| filter_unit: &CurrencyUnit, |
Contributor
There was a problem hiding this comment.
I think you want this to be and Option and filter if it's not None
Collaborator
|
Close for #1930 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves how the global
--unitflag is parsed and howbalanceuses it, so the CLI no longer misleads users about which currency unit they are acting on. Plural aliases and a typo check align input with Cashu’s standard units;--unitis global so it works both before and after the subcommand.issues i faced
Ambiguous or misleading unit handling
A typo or odd string could still parse as a custom unit, so what i typed did not match what i saw on the screen. For example, a mistyped unit could still show sat balances as if nothing was wrong:
balanceand--unit--unitdid not line up with what i expected forbalance. Asking for non-matching unit could still show sat totals. And putting--unitafter the subcommand failed entirely:Whereas putting
--unitbefore the command still did not filter to that unit when you only held sat:Empty
--unitPassing an empty value looked like “no unit,” but the tool still behaved like a normal sat run, which is not the same as omitting
--uniton purpose:What this PR changes
satt, clear error for empty--unit(omit the flag for defaultsat).balancerespects the resolved unit (defaultsatwhen--unitis omitted).global = trueon--unitsocdk balance --unit usdandcdk --unit usd balanceare equivalent.