Skip to content

feat: Add valid config fields to its help#217

Merged
dbolson merged 4 commits into
mainfrom
sc-242343/config-help
Apr 30, 2024
Merged

feat: Add valid config fields to its help#217
dbolson merged 4 commits into
mainfrom
sc-242343/config-help

Conversation

@dbolson
Copy link
Copy Markdown
Contributor

@dbolson dbolson commented Apr 29, 2024

Running ldcli config --help shows

View and modify specific configuration values

Current 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]

Flags:
  -h, --help           help for config
      --list           List configs
      --set            Set a config field to a value
      --unset string   Unset a config field

Global Flags:
      --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")`

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.

Comment thread README.md Outdated
The LaunchDarkly CLI allows you to save preferred settings, either within a config file using the `config` commands, or set as environment variables.

Current respected settings:
Current settings:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the readme to be consistent with the config help output.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about:

Suggested change
Current settings:
Supported settings:

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment thread cmd/config/config.go
}

helpFun := cmd.HelpFunc()
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This runs the existing help fn after updating the command's Long value.

Comment thread cmd/cliflags/flags.go
ProjectFlag = "project"
RoleFlag = "role"

AccessTokenFlagDescription = "LaunchDarkly access token with write-level access"
Copy link
Copy Markdown
Contributor Author

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.

Comment thread cmd/config/config.go
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
var sb strings.Builder
sb.WriteString("\n\nCurrent settings:\n")
for _, s := range []string{
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This uses a slice to preserve order since a map doesn't.

Comment thread README.md Outdated
The LaunchDarkly CLI allows you to save preferred settings, either within a config file using the `config` commands, or set as environment variables.

Current respected settings:
Current settings:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about:

Suggested change
Current settings:
Supported settings:

?

Comment thread README.md Outdated

* `access-token` A LaunchDarkly API token with write-level access
* `access-token` A LaunchDarkly access token with write-level access
* `analytics-optout` Opt out of analytics tracking (default false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* `analytics-optout` Opt out of analytics tracking (default false)
* `analytics-opt-out` Opt out of analytics tracking (default false)

Comment thread cmd/config/config.go Outdated
helpFun := cmd.HelpFunc()
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
var sb strings.Builder
sb.WriteString("\n\nCurrent settings:\n")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about:

Suggested change
sb.WriteString("\n\nCurrent settings:\n")
sb.WriteString("\n\nSupported settings:\n")

?

@@ -10,7 +16,7 @@ Flags:
--unset string Unset a config field
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 --unset is marked as taking a string parameter whereas --set isn't marked to have any parameter. It should also have string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dbolson dbolson merged commit ffa9fb3 into main Apr 30, 2024
@dbolson dbolson deleted the sc-242343/config-help branch April 30, 2024 15:43
@sunnyguduru sunnyguduru mentioned this pull request Apr 30, 2024
3 tasks
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