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

refactor: update clap to v3 #3370

Merged
merged 6 commits into from
Jan 4, 2022
Merged

refactor: update clap to v3 #3370

merged 6 commits into from
Jan 4, 2022

Conversation

davidkna
Copy link
Member

@davidkna davidkna commented Dec 31, 2021

Description

Updates clap to v3. I switched the implementation to the new derive/structopt style because there were so many breaking changes.
Completions are now handled by clap-completions. I changed some arguments to allow setting them from environment variables. Shared module/prompt/explain arguments are now handled by context::Properties and --right/--continuation are handled separately for prompt and passed on as a Target (the other subcommands ignore target and set it to Main).

Motivation and Context

Closes #

Screenshots (if appropriate):

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@chipbuster
Copy link
Contributor

This will likely need to be rebased on #3322 (which just got approved)

@davidkna davidkna force-pushed the clap3 branch 2 times, most recently from 25c2c3f to 050b893 Compare January 1, 2022 13:57
@davidkna
Copy link
Member Author

davidkna commented Jan 1, 2022

Removed the feature of giving arguments with environment variables, because they overwrite explicit arguments.

Copy link
Member

@matchai matchai left a comment

Choose a reason for hiding this comment

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

LGTM. Just a couple small comments 👍

src/context.rs Show resolved Hide resolved
src/context.rs Outdated

/// Properties as passed on from the shell as arguments
#[derive(Parser, Debug)]

Copy link
Member

Choose a reason for hiding this comment

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

nitpick: Looks like a lingering newline was left here between the attribute and the definition 😄

Suggested change

}

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Target {
Copy link
Member

Choose a reason for hiding this comment

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

Could we add a doc comment here explaining what Target is?

src/main.rs Show resolved Hide resolved
Explain(Properties),
/// Prints the shell function used to execute starship
Init {
shell: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

We could instead create an enum with all supported shell types and derive ArgEnum for it

Copy link
Member Author

@davidkna davidkna Jan 3, 2022

Choose a reason for hiding this comment

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

I didn't do that because passing the shell path is also supported for this argument. Also, how to handle unknown shell names will require some thought. By the way, context.rs already defines a Shell enum.

@matchai matchai merged commit 20cf200 into starship:master Jan 4, 2022
@davidkna davidkna deleted the clap3 branch March 26, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants