format

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 10 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

cmd/product/format/format.go

Index

Constants

This section is empty.

Variables

View Source
var FormatCmd = &cobra.Command{
	Use:     "format",
	Example: `  contextvibes product format  # Apply formatting and fixes to the project`,
	Args:    cobra.NoArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		presenter.Summary("Applying code formatting and auto-fixes.")

		cwd, err := os.Getwd()
		if err != nil {
			presenter.Error("Failed to get current working directory: %v", err)
			return err
		}

		projType, err := project.Detect(cwd)
		if err != nil {
			presenter.Error("Failed to detect project type: %v", err)
			return err
		}
		presenter.Info("Detected project type: %s", presenter.Highlight(string(projType)))

		var formatErrors []error

		switch projType {
		case project.Go:
			presenter.Header("Go Formatting & Lint Fixes")
			err := runFormatCommand(ctx, presenter, globals.ExecClient, cwd, "golangci-lint", []string{"run", "--fix"})
			if err != nil {
				presenter.Warning("'golangci-lint --fix' completed but may have found unfixable issues.")
			} else {
				presenter.Success("✓ golangci-lint completed.")
			}

		}

		presenter.Newline()
		if len(formatErrors) > 0 {
			return errors.New("one or more formatting tools failed")
		}

		presenter.Success("All formatting and auto-fixing tools completed.")
		return nil
	},
}

FormatCmd represents the format 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