init_cmd

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

cmd/factory/init/init.go

Index

Constants

This section is empty.

Variables

View Source
var InitCmd = &cobra.Command{
	Use: "init",
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		presenter.Summary("Initializing ContextVibes configuration...")

		stdout, stderr, err := globals.ExecClient.CaptureOutput(
			ctx,
			".",
			"git",
			"rev-parse",
			"--show-toplevel",
		)
		if err != nil {
			presenter.Error("Failed to determine project root. Are you inside a Git repository?")
			presenter.Detail("Stderr: %s", stderr)

			return errors.New("not a git repository")
		}
		projectRoot := strings.TrimSpace(stdout)
		configPath := filepath.Join(projectRoot, config.DefaultConfigFileName)

		if _, err := os.Stat(configPath); err == nil {
			presenter.Info("Configuration file already exists: %s", presenter.Highlight(configPath))

			return nil
		}

		defaultConfig := config.GetDefaultConfig()
		if err := config.UpdateAndSaveConfig(defaultConfig, configPath); err != nil {
			return err
		}

		presenter.Success("Successfully created .contextvibes.yaml.")

		return nil
	},
}

InitCmd represents the init command.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL