Skip to content
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

feat(cli): Add example to --help output for app actions #15822

Merged
merged 1 commit into from
Oct 6, 2023
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
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
Loading