-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Add valid config fields to its help #217
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "encoding/json" | ||
| "fmt" | ||
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/viper" | ||
|
|
@@ -39,6 +40,22 @@ func NewConfigCmd(analyticsTracker analytics.Tracker) *cobra.Command { | |
| }, | ||
| } | ||
|
|
||
| helpFun := cmd.HelpFunc() | ||
| cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This runs the existing help fn after updating the command's |
||
| var sb strings.Builder | ||
| sb.WriteString("\n\nSupported settings:\n") | ||
| for _, s := range []string{ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This uses a slice to preserve order since a map doesn't. |
||
| cliflags.AccessTokenFlag, | ||
| cliflags.AnalyticsOptOut, | ||
| cliflags.BaseURIFlag, | ||
| cliflags.OutputFlag, | ||
| } { | ||
| sb.WriteString(fmt.Sprintf("- `%s`: %s\n", s, cliflags.AllFlagsHelp()[s])) | ||
| } | ||
| cmd.Long += sb.String() | ||
| helpFun(cmd, args) | ||
| }) | ||
|
|
||
| cmd.Flags().Bool(ListFlag, false, "List configs") | ||
| _ = viper.BindPFlag(ListFlag, cmd.Flags().Lookup(ListFlag)) | ||
| cmd.Flags().Bool(SetFlag, false, "Set a config field to a value") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| View and modify specific configuration values | ||
|
|
||
| Supported settings: | ||
| - `access-token`: LaunchDarkly access token with write-level access | ||
| - `analytics-opt-out`: Opt out of analytics tracking | ||
| - `base-uri`: LaunchDarkly base URI | ||
| - `output`: Command response output format in either JSON or plain text | ||
|
|
||
| Usage: | ||
| ldcli config [flags] | ||
|
|
||
|
|
@@ -10,7 +16,7 @@ Flags: | |
| --unset string Unset a config field | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor (and I know, I'm tagging this on a test file) but I noticed that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| Global Flags: | ||
| --access-token string LaunchDarkly API token with write-level access | ||
| --access-token string LaunchDarkly access token with write-level access | ||
| --analytics-opt-out Opt out of analytics tracking | ||
| --base-uri string LaunchDarkly base URI (default "https://app.launchdarkly.com") | ||
| -o, --output string Command response output format in either JSON or plain text (default "plaintext") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these to constants to remove duplication.