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: Add config command #175

Merged
merged 2 commits into from
Apr 16, 2024
Merged

feat: Add config command #175

merged 2 commits into from
Apr 16, 2024

Conversation

dbolson
Copy link
Contributor

@dbolson dbolson commented Apr 15, 2024

Adds a config command with three flags:

  • ldcli config --list -- shows the values in the current config file
  • ldcli config --set foo bar -- adds the key "foo" with value "bar" to the config file if it's a relevant key
  • ldcli config --unset foo -- removes "foo" from the config file if it exists

This PR only sets up the command with the flags and doesn't do anything yet.

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.

if cmd.Name() == "help" || cmd.Parent().Name() == "completion" {
cmd.DisableFlagParsing = true
// disable required flags when running certain commands
for _, name := range []string{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also fixes a bug where running ldcli completion bash would would flags which it shouldn't.

fmt.Fprintln(cmd.OutOrStdout(), "called --list flag")
case viper.GetBool(SetFlag):
fmt.Fprintln(cmd.OutOrStdout(), "called --set flag")
case viper.GetBool(UnsetFlag):
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be viper.GetString(UnsetFlag) instead?

* Find or create config file when reading values from it

* Write config file after running config commands

* feat: add config set flag (#177)

* Adds support for ldcli config --set

The set flag takes a key/value pair and writes them to the config file
if they are relevant. It ignores arbitrary keys and for now only
supports:

* access-token
* base-uri

* Add config unset flag (#178)

The unset flag takes a value removes it from the config file if
it is relevant. It ignores arbitrary keys and for now only supports:

access-token
base-uri
@dbolson dbolson merged commit c1feb53 into main Apr 16, 2024
2 checks passed
@dbolson dbolson deleted the sc-240202/add-config-cmd branch April 16, 2024 20:31
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.

3 participants