Skip to content

Commit

Permalink
feat: add cli usage example
Browse files Browse the repository at this point in the history
Signed-off-by: xiaowu.zhu <xiaowu.zhu@daocloud.io>
  • Loading branch information
yyzxw authored and xiaowu.zhu committed May 24, 2024
1 parent 4d8f972 commit d1e0e2c
Show file tree
Hide file tree
Showing 44 changed files with 408 additions and 8 deletions.
3 changes: 3 additions & 0 deletions cmd/argo/commands/archive/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ func NewDeleteCommand() *cobra.Command {
command := &cobra.Command{
Use: "delete UID...",
Short: "delete a workflow in the archive",
Example: `# Delete an archived workflow
argo archive delete uid1 uid2 uid3`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewArchivedWorkflowServiceClient()
Expand Down
3 changes: 3 additions & 0 deletions cmd/argo/commands/archive/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ func NewGetCommand() *cobra.Command {
command := &cobra.Command{
Use: "get UID",
Short: "get a workflow in the archive",
Example: `# Get an archived workflow
argo archive get uid`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
cmd.HelpFunc()(cmd, args)
Expand Down
19 changes: 17 additions & 2 deletions cmd/argo/commands/archive/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,30 @@ import (
"github.com/argoproj/argo-workflows/v3/util/printer"
)

var (
listExample = `# List all archived workflows
argo archive list
# List archived workflows with label selector
argo archive list -l workflows.argoproj.io/test=true
# List archived workflows in JSON format
argo archive list -o json`
)

func NewListCommand() *cobra.Command {
var (
selector string
output string
chunkSize int64
)
command := &cobra.Command{
Use: "list",
Short: "list workflows in the archive",
Use: "list",
Short: "list workflows in the archive",
Example: listExample,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewArchivedWorkflowServiceClient()
Expand Down
3 changes: 3 additions & 0 deletions cmd/argo/commands/archive/list_label_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ func NewListLabelKeyCommand() *cobra.Command {
command := &cobra.Command{
Use: "list-label-keys",
Short: "list workflows label keys in the archive",
Example: `# List archived workflow label keys
argo archive list-label-keys`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewArchivedWorkflowServiceClient()
Expand Down
3 changes: 3 additions & 0 deletions cmd/argo/commands/archive/list_label_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func NewListLabelValueCommand() *cobra.Command {
command := &cobra.Command{
Use: "list-label-values",
Short: "get workflow label values in the archive",
Example: `# List archived workflow label values
argo archive list-label-values -l key1`,
Run: func(cmd *cobra.Command, args []string) {
listOpts := &metav1.ListOptions{
LabelSelector: selector,
Expand Down
3 changes: 3 additions & 0 deletions cmd/argo/commands/auth/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ func NewTokenCommand() *cobra.Command {
return &cobra.Command{
Use: "token",
Short: "Print the auth token",
Example: `# Print the auth token
argo auth token`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 {
cmd.HelpFunc()(cmd, args)
Expand Down
15 changes: 13 additions & 2 deletions cmd/argo/commands/clustertemplate/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ import (
"github.com/argoproj/argo-workflows/v3/pkg/apiclient/clusterworkflowtemplate"
)

var (
deleteExample = `# Delete one or more cluster workflow templates
argo cluster-template delete cwf-template-name1 cwf-template-name2
# Delete all cluster workflow templates
argo cluster-template delete --all`
)

// NewDeleteCommand returns a new instance of an `argo delete` command
func NewDeleteCommand() *cobra.Command {
var all bool

command := &cobra.Command{
Use: "delete WORKFLOW_TEMPLATE",
Short: "delete a cluster workflow template",
Use: "delete WORKFLOW_TEMPLATE",
Short: "delete a cluster workflow template",
Example: deleteExample,
Run: func(cmd *cobra.Command, args []string) {
apiServerDeleteClusterWorkflowTemplates(cmd.Context(), all, args)
},
Expand Down
3 changes: 3 additions & 0 deletions cmd/argo/commands/clustertemplate/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ func NewGetCommand() *cobra.Command {
command := &cobra.Command{
Use: "get CLUSTER WORKFLOW_TEMPLATE...",
Short: "display details about a cluster workflow template",
Example: `# Get details about a cluster workflow template
argo cluster-template get my-cluster-workflow-template -o wide`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewClusterWorkflowTemplateServiceClient()
Expand Down
3 changes: 3 additions & 0 deletions cmd/argo/commands/clustertemplate/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func NewLintCommand() *cobra.Command {
command := &cobra.Command{
Use: "lint FILE...",
Short: "validate files or directories of cluster workflow template manifests",
Example: `# Validate cluster workflow template manifest
argo cluster-template lint FILE1 FILE2`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
Expand Down
23 changes: 21 additions & 2 deletions cmd/argo/commands/cron/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,34 @@ type cliCreateOpts struct {
strict bool // --strict
}

var (
createCronWFExample = `# Create a cron workflow from a file
argo cron create FILE1
# Create a cron workflow and print it as YAML
argo cron create FILE1 --output yaml
# Create a cron workflow with relaxed validation
argo cron create FILE1 --strict false
# Create a cron workflow with a custom schedule(override the schedule in the cron workflow)
argo cron create FILE1 --schedule "0 0 * * *"`
)

func NewCreateCommand() *cobra.Command {
var (
cliCreateOpts cliCreateOpts
submitOpts wfv1.SubmitOpts
parametersFile string
)
command := &cobra.Command{
Use: "create FILE1 FILE2...",
Short: "create a cron workflow",
Use: "create FILE1 FILE2...",
Short: "create a cron workflow",
Example: createCronWFExample,
Run: func(cmd *cobra.Command, args []string) {
checkArgs(cmd, args, parametersFile, &submitOpts)

Expand Down
8 changes: 8 additions & 0 deletions cmd/argo/commands/cron/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ func NewDeleteCommand() *cobra.Command {
command := &cobra.Command{
Use: "delete [CRON_WORKFLOW... | --all]",
Short: "delete a cron workflow",
Example: `# Delete a cron workflow
argo cron delete my-cron-workflow
# Delete all cron workflows
argo cron delete --all
`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewCronWorkflowServiceClient()
Expand Down
8 changes: 8 additions & 0 deletions cmd/argo/commands/cron/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ func NewGetCommand() *cobra.Command {
command := &cobra.Command{
Use: "get CRON_WORKFLOW...",
Short: "display details about a cron workflow",
Example: `# Display details about a cron workflow
argo cron get my-cron-workflow
# Display details about multiple cron workflows printed as YAML
argo cron get my-cron-workflow -o yaml
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
Expand Down
4 changes: 4 additions & 0 deletions cmd/argo/commands/cron/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func NewLintCommand() *cobra.Command {
command := &cobra.Command{
Use: "lint FILE...",
Short: "validate files or directories of cron workflow manifests",
Example: `# Validate cron workflow manifest
argo cron lint FILE1 FILE2
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
Expand Down
23 changes: 21 additions & 2 deletions cmd/argo/commands/cron/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,30 @@ type listFlags struct {
labelSelector string // --selector
}

var (
listCronWFExample = `# List all cron workflows
argo cron list
# List all cron workflows in all namespaces
argo cron list --all-namespaces
# List all cron workflows in all namespaces with a label selector
argo cron list --all-namespaces --selector key1=value1,key2=value2
# List all cron workflows in all namespaces and output only the names
argo cron list --all-namespaces --output name`
)

func NewListCommand() *cobra.Command {
var listArgs listFlags
command := &cobra.Command{
Use: "list",
Short: "list cron workflows",
Use: "list",
Short: "list cron workflows",
Example: listCronWFExample,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewCronWorkflowServiceClient()
Expand Down
4 changes: 4 additions & 0 deletions cmd/argo/commands/cron/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func NewResumeCommand() *cobra.Command {
command := &cobra.Command{
Use: "resume [CRON_WORKFLOW...]",
Short: "resume zero or more cron workflows",
Example: `# Resume a cron workflow
argo cron resume my-cron-workflow
`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewCronWorkflowServiceClient()
Expand Down
4 changes: 4 additions & 0 deletions cmd/argo/commands/cron/suspend.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func NewSuspendCommand() *cobra.Command {
command := &cobra.Command{
Use: "suspend CRON_WORKFLOW...",
Short: "suspend zero or more cron workflows",
Example: `# Suspend a cron workflow
argo cron suspend my-cron-workflow
`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewCronWorkflowServiceClient()
Expand Down
4 changes: 4 additions & 0 deletions cmd/argo/commands/executorplugin/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func NewBuildCommand() *cobra.Command {
Use: "build DIR",
Short: "build an executor plugin",
SilenceUsage: true,
Example: `# Build an executor plugin
argo executor-plugin build my-executor-plugin/
`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
cmd.HelpFunc()(cmd, args)
Expand Down
7 changes: 7 additions & 0 deletions cmd/argo/commands/template/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ func NewCreateCommand() *cobra.Command {
command := &cobra.Command{
Use: "create FILE1 FILE2...",
Short: "create a workflow template",
Example: `# Create a workflow template from a file
argo template create FILE1
# Create a workflow template and print the result in YAML format
argo template create FILE1 -o yaml`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
Expand Down
7 changes: 7 additions & 0 deletions cmd/argo/commands/template/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ func NewDeleteCommand() *cobra.Command {
command := &cobra.Command{
Use: "delete WORKFLOW_TEMPLATE",
Short: "delete a workflow template",
Example: `# Delete a workflow template
argo template delete my-wftmpl
# Delete all workflow templates
argo template delete --all`,
Run: func(cmd *cobra.Command, args []string) {
apiServerDeleteWorkflowTemplates(cmd.Context(), all, args)
},
Expand Down
7 changes: 7 additions & 0 deletions cmd/argo/commands/template/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func NewGetCommand() *cobra.Command {
command := &cobra.Command{
Use: "get WORKFLOW_TEMPLATE...",
Short: "display details about a workflow template",
Example: `# Display details about a workflow template
argo template get my-wftmpl
# Display details about multiple workflow templates printed as YAML
argo template get my-wftmpl1 my-wftmpl2 -o yaml
`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewWorkflowTemplateServiceClient()
Expand Down
8 changes: 8 additions & 0 deletions cmd/argo/commands/template/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ func NewLintCommand() *cobra.Command {
command := &cobra.Command{
Use: "lint (DIRECTORY | FILE1 FILE2 FILE3...)",
Short: "validate a file or directory of workflow template manifests",
Example: `# Validate a workflow template
argo template lint my-wftmpl.yaml
# Validate all workflow templates in a directory
argo template lint my-wftmpls/
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.HelpFunc()(cmd, args)
Expand Down
7 changes: 7 additions & 0 deletions cmd/argo/commands/template/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ func NewListCommand() *cobra.Command {
command := &cobra.Command{
Use: "list",
Short: "list workflow templates",
Example: `# List workflow templates
argo template list
# List workflow templates in all namespaces
argo template list --all-namespaces`,
Run: func(cmd *cobra.Command, args []string) {
ctx, apiClient := client.NewAPIClient(cmd.Context())
serviceClient, err := apiClient.NewWorkflowTemplateServiceClient()
Expand Down
8 changes: 8 additions & 0 deletions docs/cli/argo_archive_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ delete a workflow in the archive
argo archive delete UID... [flags]
```

### Examples

```
# Delete an archived workflow
argo archive delete uid1 uid2 uid3
```

### Options

```
Expand Down
8 changes: 8 additions & 0 deletions docs/cli/argo_archive_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ get a workflow in the archive
argo archive get UID [flags]
```

### Examples

```
# Get an archived workflow
argo archive get uid
```

### Options

```
Expand Down
8 changes: 8 additions & 0 deletions docs/cli/argo_archive_list-label-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ list workflows label keys in the archive
argo archive list-label-keys [flags]
```

### Examples

```
# List archived workflow label keys
argo archive list-label-keys
```

### Options

```
Expand Down
Loading

0 comments on commit d1e0e2c

Please sign in to comment.