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

Function InitCmd

cli/cmd/initialize/init.go:21–249  ·  view source on GitHub ↗
(ch *cmdutil.Helper)

Source from the content-addressed store, hash-verified

19)
20
21func InitCmd(ch *cmdutil.Helper) *cobra.Command {
22 var olap string
23 var example string
24 var agent string
25
26 exampleOptions, _ := examples.List()
27
28 var long strings.Builder
29 long.WriteString("Initialize a new Rill project. Use flags to customize the project or run interactively to be prompted for each option.")
30 if len(exampleOptions) > 0 {
31 long.WriteString("\n\nAvailable example projects:\n")
32 for _, ex := range exampleOptions {
33 fmt.Fprintf(&long, " - %s (%s)\n", ex.Name, ex.OLAPConnector)
34 }
35 }
36
37 initCmd := &cobra.Command{
38 Use: "init [<path>]",
39 Short: "Initialize a new Rill project",
40 Long: long.String(),
41 Example: ` # Interactive initialization (prompts for all options)
42 rill init
43
44 # Create an empty DuckDB project with Claude agent instructions
45 rill init my-project --olap duckdb --agent claude
46
47 # Add Claude agent instructions to an existing Rill project
48 rill init ./existing-project --agent claude`,
49 RunE: func(cmd *cobra.Command, args []string) error {
50 // Assess what flags were set
51 numFlags := 0
52 explicitOlap := false
53 explicitAgent := false
54 if cmd.Flags().Changed("olap") {
55 numFlags++
56 explicitOlap = true
57 }
58 if cmd.Flags().Changed("example") {
59 numFlags++
60 }
61 if cmd.Flags().Changed("agent") {
62 numFlags++
63 explicitAgent = true
64 }
65
66 // Resolve project path:
67 // - If a path arg is provided, use it directly.
68 // - If cwd contains rill.yaml, default to cwd.
69 // - Otherwise prompt interactively.
70 var projectPath string
71 if len(args) > 0 {
72 projectPath = args[0]
73 } else if cmdutil.HasRillProject(".") {
74 projectPath = "."
75 } else {
76 if !ch.Interactive {
77 return fmt.Errorf("project path argument is required when not running interactively")
78 }

Callers 1

RootCmdFunction · 0.92

Calls 15

ListFunction · 0.92
HasRillProjectFunction · 0.92
InputPromptFunction · 0.92
ExpandHomeFunction · 0.92
RepoForProjectPathFunction · 0.92
SelectPromptFunction · 0.92
InitEmptyFunction · 0.92
GetFunction · 0.92
ShellEscapeFunction · 0.92
writeAgentInstructionsFunction · 0.85
PrintfMethod · 0.80
ContainsMethod · 0.80

Tested by

no test coverage detected