fix(cli): persist selected network and use as default across invocations (closes #10) - #17
Open
ghzhost wants to merge 1 commit into
Open
fix(cli): persist selected network and use as default across invocations (closes #10)#17ghzhost wants to merge 1 commit into
ghzhost wants to merge 1 commit into
Conversation
Contributor
|
@ghzhost kindly resolve conflicts |
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.
Summary
Persists the selected network (via
Commands::Switchor disk storage) so subsequent commands default to the previously chosen network rather than silently resetting to Mainnet on every invocation.Changes
src/utils/mod.rs):save_current_network/save_networkandget_current_networkto persist/load network preference from~/.txio/current_networkmirroring the existingcurrent_chainmechanism.src/cli/parser.rs):--networkflag optional (Option<Network>) so CLI invocations can distinguish between explicitly passing a network and omitting it to fall back to the persisted setting.FromStrforNetwork.Commands::Switchto accept optionalchain: Option<String>and optional--networkflag (network: Option<Network>).src/cli/handlers.rs):CommandHandler::resolve_network(explicit_network: Option<Network>) -> Networkimplementing the precedence:--networkflag (if provided).~/.txio/current_network(if present and valid).Network::Mainnet.Commands::Switchto persist network when--networkis supplied, along with chain switching.Commands::Statusand all chain command adapters (Sui,Ethereum,Solana,Aptos,Soroban) to use the effective network.src/utils/mod.rsfor network persistence round-trip.src/cli/handlers.rsforresolve_networkprecedence (first run default, persisted setting, and explicit override).Closes #10