Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pingcli
# Ping CLI

The Ping CLI is a unified command line interface for configuring and managing Ping Identity Services.

Expand All @@ -15,7 +15,7 @@ Start by running the command to create a new profile and answering the prompts.
```text
$ pingcli config add-profile
Pingcli configuration file '/Users/<me>/.pingcli/config.yaml' does not exist. - No Action (Warning)
Creating new pingcli configuration file at: /Users/<me>/.pingcli/config.yaml
Creating new Ping CLI configuration file at: /Users/<me>/.pingcli/config.yaml
New profile name: : dev
New profile description: : configuration for development environment
Set new profile as active: : y
Expand Down
21 changes: 14 additions & 7 deletions cmd/config/add_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@ import (
)

const (
addProfilecommandExamples = ` pingcli config add-profile
pingcli config add-profile --name myprofile --description "My Profile desc"
pingcli config add-profile --set-active=true`
addProfilecommandExamples = ` Add a new configuration profile with a guided experience.
pingcli config add-profile

Add a new configuration profile with a specific name and description.
pingcli config add-profile --name MyDeveloperEnv --description "My awesome new profile for my development environment"

Add a new configuration profile with a guided experience and set it as the active profile.
pingcli config add-profile --set-active=true`
)

func NewConfigAddProfileCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: addProfilecommandExamples,
Long: `Add a new configuration profile to pingcli.`,
RunE: configAddProfileRunE,
Short: "Add a new configuration profile to pingcli.",
Use: "add-profile [flags]",
Long: `Add a new custom configuration profile to the CLI.

The new configuration profile will be stored in the CLI configuration file.`,
RunE: configAddProfileRunE,
Short: "Add a new custom configuration profile.",
Use: "add-profile [flags]",
}

cmd.Flags().AddFlag(options.ConfigAddProfileNameOption.Flag)
Expand Down
6 changes: 4 additions & 2 deletions cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ func NewConfigCommand() *cobra.Command {
// Args: common.ExactArgs(0),
// DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
// Example: configCommandExamples,
Long: `A set of command for profile configuration management.`,
Long: "Manage the configuration of the CLI, including Ping product connection parameters.\n\n" +
"The Ping CLI supports the use of configuration profiles.\nConfiguration profiles can be used when connecting to multiple environments using the same Ping CLI instance, such as when managing multiple development or demonstration environments.\n\n" +
"A pre-defined default profile will be used to store the configuration of the CLI.\nAdditional custom profiles can be created using the `pingcli config add-profile` command.\nTo use a custom profile, the `--profile` flag can be used on supported commands to specify the profile to use for that command.\nTo set a custom profile as the default, use the `pingcli config set-active-profile` command.",
// RunE: configRunE,
Short: "A set of command for profile configuration management.",
Short: "Manage the CLI configuration.",
Use: "config",
}

Expand Down
17 changes: 11 additions & 6 deletions cmd/config/delete_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@ import (
)

const (
deleteProfileCommandExamples = ` pingcli config delete-profile
pingcli config delete-profile --profile myprofile`
deleteProfileCommandExamples = ` Delete a configuration profile by selecting from the available profiles.
pingcli config delete-profile

Delete a configuration profile by specifying the name of an existing configured profile.
pingcli config delete-profile --profile MyDeveloperEnv`
)

func NewConfigDeleteProfileCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: deleteProfileCommandExamples,
Long: `Delete a configuration profile from pingcli.`,
RunE: configDeleteProfileRunE,
Short: "Delete a configuration profile from pingcli.",
Use: "delete-profile [flags]",
Long: `Delete an existing custom configuration profile from the CLI.

The profile to delete will be removed from the CLI configuration file.`,
RunE: configDeleteProfileRunE,
Short: "Delete a custom configuration profile.",
Use: "delete-profile [flags]",
}

cmd.Flags().AddFlag(options.ConfigDeleteProfileOption.Flag)
Expand Down
21 changes: 14 additions & 7 deletions cmd/config/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ import (
)

const (
configGetCommandExamples = ` pingcli config get pingone
pingcli config get --profile myProfile color
pingcli config get service.pingone.authentication.worker.environmentID`
configGetCommandExamples = ` Read all the configuration settings for the PingOne service in the active (or default) profile.
pingcli config get pingone

Read the color setting for the profile named 'myProfile'.
pingcli config get --profile myProfile color

Read the worker ID used to authenticate to the PingOne service management API.
pingcli config get service.pingone.authentication.worker.environmentID`
)

func NewConfigGetCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(1),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: configGetCommandExamples,
Long: `Get pingcli configuration settings.`,
RunE: configGetRunE,
Short: "Get pingcli configuration settings.",
Use: "get [flags] key",
Long: "Read stored configuration settings for the CLI.\n\n" +
"The `--profile` parameter can be used to read configuration settings for a specified custom configuration profile.\n" +
"Where `--profile` is not specified, configuration settings will be read for the currently active profile.",
RunE: configGetRunE,
Short: "Read stored configuration settings for the CLI.",
Use: "get [flags] key",
}

cmd.Flags().AddFlag(options.ConfigGetProfileOption.Flag)
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestConfigGetCmd_TooManyArgs(t *testing.T) {

// Test Config Get Command Executes when provided a full key
func TestConfigGetCmd_FullKey(t *testing.T) {
err := testutils_cobra.ExecutePingcli(t, "config", "get", options.PingoneAuthenticationWorkerClientIDOption.ViperKey)
err := testutils_cobra.ExecutePingcli(t, "config", "get", options.PingOneAuthenticationWorkerClientIDOption.ViperKey)
testutils.CheckExpectedError(t, err, nil)
}

Expand Down
7 changes: 4 additions & 3 deletions cmd/config/list_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
)

const (
listProfilesCommandExamples = ` pingcli config list-profiles`
listProfilesCommandExamples = ` List all custom configuration profiles stored in the CLI configuration file.
pingcli config list-profiles`
)

func NewConfigListProfilesCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: listProfilesCommandExamples,
Long: `List all configuration profiles from pingcli.`,
Long: `List all custom configuration profiles stored in the CLI configuration file.`,
RunE: configListProfilesRunE,
Short: "List all configuration profiles from pingcli.",
Short: "List all custom configuration profiles.",
Use: "list-profiles",
}

Expand Down
17 changes: 11 additions & 6 deletions cmd/config/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import (
)

const (
configSetCommandExamples = ` pingcli config set color=true
pingcli config set --profile myProfile service.pingone.regionCode=AP`
configSetCommandExamples = ` Set the color setting to true for the currently active profile.
pingcli config set color=true

Set the PingOne tenant region code setting to 'AP' for the profile named 'myProfile'.
pingcli config set --profile myProfile service.pingone.regionCode=AP`
)

func NewConfigSetCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(1),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: configSetCommandExamples,
Long: `Set pingcli configuration settings.`,
RunE: configSetRunE,
Short: "Set pingcli configuration settings.",
Use: "set [flags] key=value",
Long: "Set stored configuration settings for the CLI.\n\n" +
"The `--profile` parameter can be used to set configuration settings for a specified custom configuration profile.\n" +
"Where `--profile` is not specified, configuration settings will be set for the currently active profile.",
RunE: configSetRunE,
Short: "Set stored configuration settings for the CLI.",
Use: "set [flags] key=value",
}

cmd.Flags().AddFlag(options.ConfigSetProfileOption.Flag)
Expand Down
11 changes: 7 additions & 4 deletions cmd/config/set_active_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ import (
)

const (
setActiveProfileCommandExamples = ` pingcli config set-active-profile
pingcli config set-active-profile --profile myprofile`
setActiveProfileCommandExamples = ` Set an active profile with an interactive prompt to select from an available profile.
pingcli config set-active-profile

Set an active profile with a specific profile name.
pingcli config set-active-profile --profile myprofile`
)

func NewConfigSetActiveProfileCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: setActiveProfileCommandExamples,
Long: `Set a configuration profile as the in-use profile for pingcli.`,
Long: `Set a custom configuration profile as the in-use profile.`,
RunE: configSetActiveProfileRunE,
Short: "Set a configuration profile as the in-use profile for pingcli.",
Short: "Set a custom configuration profile as the in-use profile.",
Use: "set-active-profile [flags]",
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/config/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestConfigSetCmd_NoValueProvided(t *testing.T) {

// Test Config Set Command for key 'pingone.worker.clientId' updates viper configuration
func TestConfigSetCmd_CheckViperConfig(t *testing.T) {
viperKey := options.PingoneAuthenticationWorkerClientIDOption.ViperKey
viperKey := options.PingOneAuthenticationWorkerClientIDOption.ViperKey
viperNewUUID := "12345678-1234-1234-1234-123456789012"

err := testutils_cobra.ExecutePingcli(t, "config", "set", fmt.Sprintf("%s=%s", viperKey, viperNewUUID))
Expand Down
17 changes: 11 additions & 6 deletions cmd/config/unset.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@ import (
)

const (
configUnsetCommandExamples = ` pingcli config unset color
pingcli config unset --profile myProfile service.pingone.regionCode`
configUnsetCommandExamples = ` Unset the color setting for the currently active profile.
pingcli config unset color

Unset the PingOne tenant region code setting for the profile named 'myProfile'.
pingcli config unset --profile myProfile service.pingone.regionCode`
)

func NewConfigUnsetCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(1),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: configUnsetCommandExamples,
Long: `Unset pingcli configuration settings.`,
RunE: configUnsetRunE,
Short: "Unset pingcli configuration settings.",
Use: "unset [flags] key",
Long: "Unset stored configuration settings for the CLI.\n\n" +
"The `--profile` parameter can be used to unset configuration settings for a specified custom configuration profile.\n" +
"Where `--profile` is not specified, configuration settings will be unset for the currently active profile.",
RunE: configUnsetRunE,
Short: "Unset stored configuration settings for the CLI.",
Use: "unset [flags] key",
}

cmd.Flags().AddFlag(options.ConfigUnsetProfileOption.Flag)
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/unset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func TestConfigUnsetCmd_InvalidKey(t *testing.T) {

// Test Config Unset Command for key 'pingone.worker.clientId' updates viper configuration
func TestConfigUnsetCmd_CheckViperConfig(t *testing.T) {
viperKey := options.PingoneAuthenticationWorkerClientIDOption.ViperKey
viperOldValue := os.Getenv(options.PingoneAuthenticationWorkerClientIDOption.EnvVar)
viperKey := options.PingOneAuthenticationWorkerClientIDOption.ViperKey
viperOldValue := os.Getenv(options.PingOneAuthenticationWorkerClientIDOption.EnvVar)

err := testutils_cobra.ExecutePingcli(t, "config", "unset", viperKey)
testutils.CheckExpectedError(t, err, nil)
Expand Down
11 changes: 7 additions & 4 deletions cmd/config/view_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import (
)

const (
viewProfileCommandExamples = ` pingcli config view-profile
pingcli config view-profile --profile myprofile`
viewProfileCommandExamples = ` View configuration for the currently active profile
pingcli config view-profile

View configuration for a specific profile
pingcli config view-profile --profile myprofile`
)

func NewConfigViewProfileCommand() *cobra.Command {
cmd := &cobra.Command{
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: viewProfileCommandExamples,
Long: `View a configuration profile from pingcli.`,
Long: `View the stored configuration of a custom configuration profile.`,
RunE: configViewProfileRunE,
Short: "View a configuration profile from pingcli.",
Short: "View the stored configuration of a custom configuration profile.",
Use: "view-profile [flags]",
}

Expand Down
10 changes: 4 additions & 6 deletions cmd/feedback/feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ func NewFeedbackCommand() *cobra.Command {
Args: common.ExactArgs(0),
DisableFlagsInUseLine: true, // We write our own flags in @Use attribute
Example: ` pingcli feedback`,
Long: `A command to provide the user information
on how to give feedback or get help with the tool
through the use of the GitHub repository's issue tracker.`,
RunE: feedbackRunE,
Short: "Information on tool feedback",
Use: "feedback [flags]",
Long: "Provides links to report issues and provide feedback on using the CLI to Ping Identity.",
RunE: feedbackRunE,
Short: "Help us improve the CLI. Report issues or send us feedback on using the CLI tool.",
Use: "feedback [flags]",
}

return cmd
Expand Down
Loading