MCPcopy Create free account
hub / github.com/celer-pkg/celer / Command

Method Command

cmds/cmd_init.go:19–53  ·  view source on GitHub ↗
(celer *configs.Celer)

Source from the content-addressed store, hash-verified

17}
18
19func (i *initCmd) Command(celer *configs.Celer) *cobra.Command {
20 i.celer = celer
21 command := &cobra.Command{
22 Use: "init",
23 Short: "Init celer with configuration repository.",
24 Long: `Initialize celer with configuration repository.
25
26This command initializes celer in the current directory by creating a
27celer.toml configuration file and cloning configuration files from a
28remote Git repository.
29
30Examples:
31 celer init --url https://github.com/example/conf # Initialize with conf repo
32 celer init -u https://github.com/example/conf -b main # With specific branch
33 celer init --url https://github.com/example/conf --force # Force re-initialize`,
34 Args: cobra.NoArgs,
35 RunE: func(cmd *cobra.Command, args []string) error {
36 return i.doInit()
37 },
38 ValidArgsFunction: i.completion,
39 }
40
41 // Register flags.
42 command.Flags().StringVarP(&i.url, "url", "u", "", "URL of the configuration repository")
43 command.Flags().StringVarP(&i.branch, "branch", "b", "", "Branch of the configuration repository (default: repository's default branch)")
44 command.Flags().BoolVarP(&i.force, "force", "f", false, "Force re-initialize even if configuration exists")
45
46 // Mark url as required.
47 command.MarkFlagRequired("url")
48
49 // Silence cobra's error and usage output to avoid duplicate messages.
50 command.SilenceErrors = true
51 command.SilenceUsage = true
52 return command
53}
54
55func (i *initCmd) doInit() error {
56 i.url = strings.TrimSpace(i.url)

Callers 3

TestInitCmd_CompletionFunction · 0.95
runInitFunction · 0.95

Calls 1

doInitMethod · 0.95

Tested by 3

TestInitCmd_CompletionFunction · 0.76
runInitFunction · 0.76