Skip to content

Commit

Permalink
feat(cli): Add example to --help output for app actions (argoproj#15822)
Browse files Browse the repository at this point in the history
Signed-off-by: kokikathir <kathiresankokilavani@gmail.com>
  • Loading branch information
kokikathir authored and lukaszgyg committed Jan 12, 2024
1 parent 1c08abf commit 8d95245
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cmd/argocd/commands/app_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/argoproj/argo-cd/v2/util/templates"
"os"
"strconv"
"text/tabwriter"
Expand Down Expand Up @@ -33,11 +34,22 @@ type DisplayedAction struct {
Disabled bool
}

var (
appActionExample = templates.Examples(`
# List all the available actions for an application
argocd app actions list APPNAME
# Run an available action for an application
argocd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
`)
)

// NewApplicationResourceActionsCommand returns a new instance of an `argocd app actions` command
func NewApplicationResourceActionsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "actions",
Short: "Manage Resource actions",
Use: "actions",
Short: "Manage Resource actions",
Example: appActionExample,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
Expand All @@ -58,6 +70,10 @@ func NewApplicationResourceActionsListCommand(clientOpts *argocdclient.ClientOpt
var command = &cobra.Command{
Use: "list APPNAME",
Short: "Lists available actions on a resource",
Example: templates.Examples(`
# List all the available actions for an application
argocd app actions list APPNAME
`),
}
command.Run = func(c *cobra.Command, args []string) {
ctx := c.Context()
Expand Down Expand Up @@ -136,6 +152,10 @@ func NewApplicationResourceActionsRunCommand(clientOpts *argocdclient.ClientOpti
var command = &cobra.Command{
Use: "run APPNAME ACTION",
Short: "Runs an available action on resource(s)",
Example: templates.Examples(`
# Run an available action for an application
argocd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
`),
}

command.Flags().StringVar(&resourceName, "resource-name", "", "Name of resource")
Expand Down
10 changes: 10 additions & 0 deletions docs/user-guide/commands/argocd_app_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ Manage Resource actions
argocd app actions [flags]
```

### Examples

```
# List all the available actions for an application
argocd app actions list APPNAME
# Run an available action for an application
argocd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
```

### Options

```
Expand Down
7 changes: 7 additions & 0 deletions docs/user-guide/commands/argocd_app_actions_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Lists available actions on a resource
argocd app actions list APPNAME [flags]
```

### Examples

```
# List all the available actions for an application
argocd app actions list APPNAME
```

### Options

```
Expand Down
7 changes: 7 additions & 0 deletions docs/user-guide/commands/argocd_app_actions_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Runs an available action on resource(s)
argocd app actions run APPNAME ACTION [flags]
```

### Examples

```
# Run an available action for an application
argocd app actions run APPNAME ACTION --kind KIND [--resource-name RESOURCE] [--namespace NAMESPACE] [--group GROUP]
```

### Options

```
Expand Down

0 comments on commit 8d95245

Please sign in to comment.