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

sc-235696/add viper #8

Merged
merged 3 commits into from
Mar 11, 2024
Merged

sc-235696/add viper #8

merged 3 commits into from
Mar 11, 2024

Conversation

dbolson
Copy link
Contributor

@dbolson dbolson commented Mar 11, 2024

Adds viper to control option flags. We can use it to eventually support env vars and a config file. The next step is to add the go API client that uses the accessToken option to make a call to get projects.

Output from running go run main.go --help

LaunchDarkly CLI to control your feature flags

Usage:
  ld-cli [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  hello       A hello world command.
  help        Help about any command
  setup       Setup guide to create your first feature flag

Flags:
  -t, --accessToken string   LaunchDarkly personal access token with write-level access.
  -u, --baseUri string       LaunchDarkly base URI. (default "http://localhost:3000")
  -h, --help                 help for ld-cli

Use "ld-cli [command] --help" for more information about a command.

Output from running go run main.go hello --help

A hello world command that prints out {"hello": "world"}

Usage:
  ld-cli hello [flags]

Flags:
  -h, --help       help for hello
  -i, --informal   Make the greeting less formal

Global Flags:
  -t, --accessToken string   LaunchDarkly personal access token with write-level access.
  -u, --baseUri string       LaunchDarkly base URI. (default "http://localhost:3000")

Copy link

This pull request has been linked to Shortcut Story #235696: create command to list existing projects.

fmt.Fprintf(cmd.OutOrStdout(), "{\"hello\": \"world\"}")
},
}
func newHelloCmd() *cobra.Command {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we're going to want this pattern to eventually pass in dependencies. I'd like to move away from a global viper variable since it's implicit state, but it's easier to leave it as-is for now.

}

// bind command-specific flags
cmd.Flags().BoolP("informal", "i", false, "Make the greeting less formal")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can keep the command-specific stuff in the constructor so we don't need to do this all in the root command.

@dbolson dbolson marked this pull request as ready for review March 11, 2024 22:42
@dbolson dbolson enabled auto-merge (squash) March 11, 2024 22:47
Copy link
Contributor

@k3llymariee k3llymariee left a comment

Choose a reason for hiding this comment

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

💯

@dbolson dbolson merged commit 0e2ec3b into main Mar 11, 2024
1 check passed
@dbolson dbolson deleted the sc-235696/add-viper branch March 11, 2024 23:09
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.

2 participants