NewCmdRoot returns the base command when called without any subcommands note we explicitly pass in clientFactory and askProvider here because we configure them, which the Factory wrapper deliberately doesn't allow us to do
(f factory.Factory, clientFactory apiclient.ClientFactory, askProvider question.AskProvider)
| 35 | // note we explicitly pass in clientFactory and askProvider here because we configure them, |
| 36 | // which the Factory wrapper deliberately doesn't allow us to do |
| 37 | func NewCmdRoot(f factory.Factory, clientFactory apiclient.ClientFactory, askProvider question.AskProvider) *cobra.Command { |
| 38 | cmd := &cobra.Command{ |
| 39 | Use: "octopus <command>", |
| 40 | Short: "Octopus Deploy CLI", |
| 41 | Long: `Work seamlessly with Octopus Deploy from the command line.`, |
| 42 | } |
| 43 | |
| 44 | flags := cmd.Flags() |
| 45 | var versionParameter bool |
| 46 | flags.BoolVarP(&versionParameter, "version", "v", false, "Prints version information") |
| 47 | versionCommand := version.NewCmdVersion(f) |
| 48 | |
| 49 | // ----- Child Commands ----- |
| 50 | |
| 51 | cmd.AddCommand(versionCommand) |
| 52 | |
| 53 | // infrastructure |
| 54 | cmd.AddCommand(accountCmd.NewCmdAccount(f)) |
| 55 | cmd.AddCommand(environmentCmd.NewCmdEnvironment(f)) |
| 56 | cmd.AddCommand(ephemeralEnvironmentCmd.NewCmdEphemeralEnvironment(f)) |
| 57 | cmd.AddCommand(packageCmd.NewCmdPackage(f)) |
| 58 | cmd.AddCommand(buildInfoCmd.NewCmdBuildInformation(f)) |
| 59 | cmd.AddCommand(deploymentTargetCmd.NewCmdDeploymentTarget(f)) |
| 60 | cmd.AddCommand(workerCmd.NewCmdWorker(f)) |
| 61 | cmd.AddCommand(workerPoolCmd.NewCmdWorkerPool(f)) |
| 62 | |
| 63 | // core |
| 64 | cmd.AddCommand(projectGroupCmd.NewCmdProjectGroup(f)) |
| 65 | cmd.AddCommand(projectCmd.NewCmdProject(f)) |
| 66 | cmd.AddCommand(channelCmd.NewCmdChannel(f)) |
| 67 | cmd.AddCommand(tenantCmd.NewCmdTenant(f)) |
| 68 | cmd.AddCommand(taskCmd.NewCmdTask(f)) |
| 69 | |
| 70 | // configuration |
| 71 | cmd.AddCommand(configCmd.NewCmdConfig(f)) |
| 72 | cmd.AddCommand(spaceCmd.NewCmdSpace(f)) |
| 73 | cmd.AddCommand(loginCmd.NewCmdLogin(f)) |
| 74 | cmd.AddCommand(logoutCmd.NewCmdLogout(f)) |
| 75 | |
| 76 | cmd.AddCommand(userCmd.NewCmdUser(f)) |
| 77 | cmd.AddCommand(releaseCmd.NewCmdRelease(f)) |
| 78 | cmd.AddCommand(runbookCmd.NewCmdRunbook(f)) |
| 79 | |
| 80 | cmd.AddCommand(apiCmd.NewCmdAPI(f)) |
| 81 | |
| 82 | // ----- Configuration ----- |
| 83 | |
| 84 | // commands are expected to print their own errors to avoid double-ups |
| 85 | cmd.SilenceUsage = true |
| 86 | cmd.SilenceErrors = true |
| 87 | |
| 88 | cmdPFlags := cmd.PersistentFlags() |
| 89 | |
| 90 | cmdPFlags.BoolP(constants.FlagHelp, "h", false, "Show help for a command") |
| 91 | cmd.SetHelpFunc(rootHelpFunc) |
| 92 | cmdPFlags.StringP(constants.FlagSpace, "s", "", "Specify the space for operations") |
| 93 | |
| 94 | // remember if you read FlagOutputFormat you also need to check FlagOutputFormatLegacy |
no test coverage detected