MCPcopy Index your code
hub / github.com/rilldata/rill / RootCmd

Function RootCmd

cli/cmd/root.go:106–189  ·  view source on GitHub ↗

RootCmd creates the root command and adds all subcommands.

(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

104
105// RootCmd creates the root command and adds all subcommands.
106func RootCmd(ch *cmdutil.Helper) *cobra.Command {
107 // Build long description with agent instructions if in non-interactive mode
108 long := "Work with Rill projects from the command line."
109 if !ch.Interactive {
110 long += "\n\n"
111 long += strings.TrimSpace(agentInstructions)
112 }
113
114 // Root command
115 rootCmd := &cobra.Command{
116 Use: "rill <command> [flags]",
117 Short: "A CLI for Rill",
118 Long: long,
119 }
120 rootCmd.Version = ch.Version.String()
121 // silence usage, usage string will only show up if missing arguments/flags
122 rootCmd.SilenceUsage = true
123 // we want to override some error messages
124 rootCmd.SilenceErrors = true
125 rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage") // Overrides message for help
126 rootCmd.PersistentFlags().BoolVar(&ch.Interactive, "interactive", ch.Interactive, "Prompt for missing required parameters")
127 rootCmd.PersistentFlags().Var(&ch.Printer.Format, "format", `Output format (options: "human", "json", "csv")`)
128 rootCmd.PersistentFlags().StringVar(&ch.AdminURLOverride, "api-url", ch.AdminURLOverride, "Base URL for the cloud API")
129 if !ch.IsDev() {
130 if err := rootCmd.PersistentFlags().MarkHidden("api-url"); err != nil {
131 panic(err)
132 }
133 }
134 rootCmd.PersistentFlags().StringVar(&ch.AdminTokenOverride, "api-token", "", "Token for authenticating with the cloud API")
135 rootCmd.Flags().BoolP("version", "v", false, "Show rill version") // Adds option to get version by passing --version or -v
136
137 // Command Groups
138
139 // Project commands
140 cmdutil.AddGroup(rootCmd, "Project", false,
141 start.StartCmd(ch),
142 validate.ValidateCmd(ch),
143 initialize.InitCmd(ch),
144 deploy.DeployCmd(ch),
145 project.ProjectCmd(ch),
146 chat.ChatCmd(ch),
147 query.QueryCmd(ch),
148 publicurl.PublicURLCmd(ch),
149 env.EnvCmd(ch),
150 )
151
152 // Organization commands
153 cmdutil.AddGroup(rootCmd, "Organization", false,
154 org.OrgCmd(ch),
155 user.UserCmd(ch),
156 usergroup.UsergroupCmd(ch),
157 service.ServiceCmd(ch),
158 billing.BillingCmd(ch),
159 )
160
161 // Auth commands
162 cmdutil.AddGroup(rootCmd, "Auth", false,
163 auth.LoginCmd(ch),

Callers 2

RunWithInputMethod · 0.92
RunFunction · 0.85

Calls 15

AddGroupFunction · 0.92
StartCmdFunction · 0.92
ValidateCmdFunction · 0.92
InitCmdFunction · 0.92
DeployCmdFunction · 0.92
ProjectCmdFunction · 0.92
ChatCmdFunction · 0.92
QueryCmdFunction · 0.92
PublicURLCmdFunction · 0.92
EnvCmdFunction · 0.92
OrgCmdFunction · 0.92
UserCmdFunction · 0.92

Tested by

no test coverage detected