cli

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:     "genie",
	Short:   "Genie AI coding assistant",
	Long:    `Genie is an AI coding assistant that helps with software engineering tasks.`,
	Version: version.GetVersion(),
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		// Configure logger based on flags
		var logger logging.Logger
		if quiet {
			logger = logging.NewQuietLogger()
		} else if verbose {
			logger = logging.NewVerboseLogger()
		} else {
			logger = logging.NewDefaultLogger()
		}
		logging.SetGlobalLogger(logger)

		// Initialize Genie once for all commands
		var err error
		genieInstance, err = tui.ProvideGenie()
		if err != nil {
			return fmt.Errorf("failed to initialize Genie: %w", err)
		}

		// Start Genie with working directory and persona
		var workingDirPtr *string
		if workingDir != "" {
			workingDirPtr = &workingDir
		}

		var personaPtr *string
		if persona != "" {
			personaPtr = &persona
		}

		initialSession, err = genieInstance.Start(workingDirPtr, personaPtr)
		if err != nil {
			return err
		}

		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		// Check for stdin input before starting TUI
		var stdinContent string
		if hasStdinInput() {
			content, err := readStdinInput()
			if err != nil {
				return fmt.Errorf("failed to read stdin: %w", err)
			}
			stdinContent = content
		}

		tuiApp, err := tui.InjectTUI(initialSession)
		if err != nil {
			return err
		}
		defer tuiApp.Stop()

		return tuiApp.StartWithMessage(stdinContent)
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func NewAskCommandWithGenie

func NewAskCommandWithGenie(genieProvider func() (genie.Genie, *genie.Session)) *cobra.Command

NewAskCommandWithGenie creates an ask command that uses a pre-initialized Genie instance

Types

This section is empty.

Jump to

Keyboard shortcuts

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