status

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: 10 Imported by: 0

Documentation

Overview

Package status provides the command to show git status.

Index

Constants

This section is empty.

Variables

View Source
var StatusCmd = &cobra.Command{
	Use:     "status",
	Example: `  contextvibes factory status`,
	Args:    cobra.NoArgs,
	RunE: func(cmd *cobra.Command, _ []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		workDir, err := os.Getwd()
		if err != nil {
			return fmt.Errorf("failed to get working directory: %w", err)
		}

		gitCfg := git.GitClientConfig{
			Logger:   globals.AppLogger,
			Executor: globals.ExecClient.UnderlyingExecutor(),
		}
		client, err := git.NewClient(ctx, workDir, gitCfg)
		if err != nil {
			return fmt.Errorf("failed to initialize git client: %w", err)
		}

		stdout, _, err := client.GetStatusShort(ctx)
		if err != nil {
			return fmt.Errorf("failed to get git status: %w", err)
		}

		trimmedStdout := strings.TrimSpace(stdout)
		if trimmedStdout == "" {
			presenter.Info("Working tree is clean.")
		} else {
			presenter.InfoPrefixOnly()

			fmt.Fprintln(presenter.Out(), "  Current Changes (--short format):")
			scanner := bufio.NewScanner(strings.NewReader(trimmedStdout))
			for scanner.Scan() {

				fmt.Fprintf(presenter.Out(), "    %s\n", scanner.Text())
			}
			presenter.Newline()
		}

		return nil
	},
}

StatusCmd represents the status 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