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(config): allow printing default and computed config #2521

Merged
merged 3 commits into from Mar 31, 2021

Conversation

davidkna
Copy link
Member

@davidkna davidkna commented Mar 27, 2021

Description

This PR adds starship print-config to print the computed config and starship print-config --default to print the default config.

I made a new struct in src/configs/mod.rs that contains all the module configs and implements serve::Serialize and ModuleConfig.
Options that have a None value need to be skipped because toml doesn't support None values and a warning comment about this is added at the top of the generated config files.
Before formatting as toml the struct needs to be converted into a toml::Value because otherwise the toml crate won't be able to properly handle printing the top-level root options.
I also got rid of the wrapper struct in custom.rs because the other modules don't use this for extensiosn, folders and extensions either.

Motivation and Context

Closes #2309
Related to #1921

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. (not in-depth)
  • I have updated the tests accordingly.

@andytom andytom changed the title feat: allow printing default and computed config feat(config): allow printing default and computed config Mar 27, 2021
@davidkna davidkna marked this pull request as draft March 27, 2021 13:17
@davidkna davidkna marked this pull request as ready for review March 27, 2021 15:47
@davidkna
Copy link
Member Author

I ended up having to modify the ModuleConfig macro to use default() to make printing custom modules possible, but I think this aligns better with the general expectations for its behaviour.

@davidkna davidkna requested a review from a team March 27, 2021 17:04
Copy link
Member

@andytom andytom left a comment

Choose a reason for hiding this comment

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

LGTM

@andytom andytom merged commit d06ba07 into starship:master Mar 31, 2021
@davidkna davidkna deleted the feat-print-config branch March 26, 2022 12:53
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.

Make it easier to create initial starship.toml without jumping back&forth between config/docs
2 participants