Skip to content

Conversation

@fnando
Copy link
Member

@fnando fnando commented Dec 16, 2025

What

$ stellar keys use default
ℹ️ The default source account is set to `default`

$ stellar env
STELLAR_ACCOUNT=default # use
STELLAR_NETWORK=local   # use

$ stellar keys use --clear
ℹ️ The default source account has been cleared

$ stellar env
STELLAR_NETWORK=local # use

Why

So users have a way to clear the default identity.

Known limitations

N/A

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Dec 16, 2025
@fnando fnando requested a review from mootz12 December 16, 2025 21:26
@fnando fnando enabled auto-merge (squash) December 16, 2025 21:33
@leighmcculloch
Copy link
Member

stellar keys use --clear

The option on this keys use command doesn't feel natural or intuitive to me.

If we look at other commands for inspiration, k8s uses a separate command to clear the selected:

kubectl config use-context <context-name>
kubectl config unset current-context

What about something like:

stellar keys clear-use

And then the same with the network:

stellar network clear-use

Comment on lines -13 to +23
pub name: String,
pub name: Option<String>,

/// Clear the default source account.
#[arg(long)]
pub clear: bool,
Copy link
Member

Choose a reason for hiding this comment

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

Should we omit the clear: bool, and just make it if name is None, then clear it?

Comment on lines +33 to +39
if self.clear && self.name.is_some() {
return Err(Error::NameWithClear);
}

if !self.clear && self.name.is_none() {
return Err(Error::NameRequired);
}
Copy link
Member

Choose a reason for hiding this comment

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

If we omitted the bool, then we wouldn't need these condition checks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having clap manage this might make it easier:

clap::ArgGroup::new("Key")
    .required(true)
    .args(& ["name", "clear"]),

@fnando
Copy link
Member Author

fnando commented Dec 17, 2025

I was following @mootz12's pattern introduced on #2321. I don't have a preference, so I can move this to its own clear-use command.

Wdyt, @mootz12?

@leighmcculloch
Copy link
Member

I don't feel strongly about it. An upside is that the --clear is discoverable inside the help of the command.

Copy link
Contributor

@mootz12 mootz12 left a comment

Choose a reason for hiding this comment

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

I agree --clear probably isn't the "clear"-est naming. I think the best option would be to just use unset directly.

e.g.

stellar keys unset
stellar network unset
stellar fees unset

Thoughts @fnando @leighmcculloch ?

I'll update the #2321 for fees, maybe we could include network unset in this PR as well.

Comment on lines +33 to +39
if self.clear && self.name.is_some() {
return Err(Error::NameWithClear);
}

if !self.clear && self.name.is_none() {
return Err(Error::NameRequired);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Having clap manage this might make it easier:

clap::ArgGroup::new("Key")
    .required(true)
    .args(& ["name", "clear"]),

@github-project-automation github-project-automation bot moved this from Backlog (Not Ready) to Needs Review in DevX Dec 17, 2025
@leighmcculloch
Copy link
Member

Oh I like the 'unset' vocab. That's better than 'clear-use'.

@fnando
Copy link
Member Author

fnando commented Dec 19, 2025

Closing this in favor of #2337, which implements stellar keys unset.

@fnando fnando closed this Dec 19, 2025
auto-merge was automatically disabled December 19, 2025 14:15

Pull request was closed

@github-project-automation github-project-automation bot moved this from Needs Review to Done in DevX Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants