initcmd

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package initcmd provides the command to initialize the project configuration.

Index

Constants

This section is empty.

Variables

View Source
var InitCmd = &cobra.Command{
	Use: "init",
	RunE: func(cmd *cobra.Command, _ []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 fmt.Errorf("failed to save config: %w", 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