Skip to content

Commit

Permalink
fix: Show help when running ldcli config (#186)
Browse files Browse the repository at this point in the history
Show help when running `ldcli config`
  • Loading branch information
dbolson authored Apr 17, 2024
1 parent cc987c4 commit 92a3e51
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func run() func(*cobra.Command, []string) error {
}

return writeConfig(config, v, unsetKeyFn)
default:
return cmd.Help()
}

return nil
Expand Down
24 changes: 24 additions & 0 deletions cmd/config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package config_test

import (
"ldcli/cmd"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestNoFlag(t *testing.T) {
expected, err := os.ReadFile("testdata/help.golden")
require.NoError(t, err)
args := []string{
"config",
}

output, err := cmd.CallCmd(t, nil, nil, nil, nil, args)

require.NoError(t, err)

assert.Equal(t, string(expected), string(output))
}
14 changes: 14 additions & 0 deletions cmd/config/testdata/help.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
View and modify specific configuration values

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 API token with write-level access
--base-uri string LaunchDarkly base URI (default "https://app.launchdarkly.com")

0 comments on commit 92a3e51

Please sign in to comment.