forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
79 lines (68 loc) · 2.51 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package commands
import (
"fmt"
"github.com/argoproj/pkg/cli"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/argoproj/argo"
"github.com/argoproj/argo/cmd/argo/commands/clustertemplate"
"github.com/argoproj/argo/cmd/argo/commands/auth"
"github.com/argoproj/argo/cmd/argo/commands/cron"
"github.com/argoproj/argo/util/help"
"github.com/argoproj/argo/cmd/argo/commands/archive"
"github.com/argoproj/argo/cmd/argo/commands/client"
"github.com/argoproj/argo/cmd/argo/commands/template"
)
const (
// CLIName is the name of the CLI
CLIName = "argo"
)
// NewCommand returns a new instance of an argo command
func NewCommand() *cobra.Command {
var command = &cobra.Command{
Use: CLIName,
Short: "argo is the command line interface to Argo",
Example: fmt.Sprintf(`
If you're using the Argo Server (e.g. because you need large workflow support or workflow archive), please read %s.`, help.CLI),
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
}
command.AddCommand(NewCompletionCommand())
command.AddCommand(NewDeleteCommand())
command.AddCommand(NewGetCommand())
command.AddCommand(NewLintCommand())
command.AddCommand(NewListCommand())
command.AddCommand(NewLogsCommand())
command.AddCommand(NewResubmitCommand())
command.AddCommand(NewResumeCommand())
command.AddCommand(NewRetryCommand())
command.AddCommand(NewServerCommand())
command.AddCommand(NewSubmitCommand())
command.AddCommand(NewSuspendCommand())
command.AddCommand(auth.NewAuthCommand())
command.AddCommand(NewWaitCommand())
command.AddCommand(NewWatchCommand())
command.AddCommand(NewStopCommand())
command.AddCommand(NewTerminateCommand())
command.AddCommand(archive.NewArchiveCommand())
command.AddCommand(NewVersionCommand())
command.AddCommand(template.NewTemplateCommand())
command.AddCommand(cron.NewCronWorkflowCommand())
command.AddCommand(clustertemplate.NewClusterTemplateCommand())
client.AddKubectlFlagsToCmd(command)
client.AddArgoServerFlagsToCmd(command)
// global log level
var logLevel string
var verbose bool
command.PersistentPreRun = func(cmd *cobra.Command, args []string) {
if verbose {
logLevel = "debug"
}
cli.SetLogLevel(logLevel)
log.WithField("version", argo.GetVersion()).Debug("CLI version")
}
command.PersistentFlags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error")
command.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enabled verbose logging, i.e. --loglevel debug")
return command
}