cli

package
v0.0.0-...-627edab Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 11 Imported by: 2

Documentation

Overview

Package cli provides CLI utilities for gzh-cli tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfirmFlags

func AddConfirmFlags(cmd *cobra.Command, flags *ConfirmFlags)

AddConfirmFlags adds confirmation flags to a command.

func AddDryRunFlags

func AddDryRunFlags(cmd *cobra.Command, flags *DryRunFlags)

AddDryRunFlags adds dry-run related flags to a command.

func AddGlobalFlags

func AddGlobalFlags(cmd *cobra.Command, flags *GlobalFlags)

AddGlobalFlags adds common global flags to a command.

func AddOutputFlags

func AddOutputFlags(cmd *cobra.Command, flags *OutputFlags)

AddOutputFlags adds output formatting flags to a command.

func AddVersionCmd

func AddVersionCmd(root *cobra.Command, info VersionInfo)

AddVersionCmd adds a version subcommand with extended info.

func DryRun

func DryRun()

DryRun prints a dry-run notice.

func Error

func Error(msg string, args ...any)

Error prints an error message.

func Execute

func Execute(cmd *cobra.Command)

Execute runs the root command and handles errors.

func ExecuteWithCode

func ExecuteWithCode(cmd *cobra.Command) int

ExecuteWithCode runs the root command and returns the exit code.

func Info

func Info(msg string, args ...any)

Info prints an info message.

func NewRootCmd

func NewRootCmd(cfg RootConfig) *cobra.Command

NewRootCmd creates a new root command with standard configuration.

func Success

func Success(msg string, args ...any)

Success prints a success message.

func Warning

func Warning(msg string, args ...any)

Warning prints a warning message.

Types

type ConfirmFlags

type ConfirmFlags struct {
	Yes bool
}

ConfirmFlags holds flags for confirmation prompts.

type DryRunFlags

type DryRunFlags struct {
	DryRun bool
	Force  bool
}

DryRunFlags holds flags for dry-run mode.

type GlobalFlags

type GlobalFlags struct {
	Verbose bool
	Quiet   bool
	Debug   bool
	NoColor bool
	Config  string
}

GlobalFlags holds common flags used across all gzh-cli tools.

type Output

type Output struct {
	// contains filtered or unexported fields
}

Output handles formatted output.

func NewOutput

func NewOutput() *Output

NewOutput creates a new Output with default stdout writer.

func (*Output) DryRun

func (o *Output) DryRun()

DryRun prints a dry-run notice.

func (*Output) Error

func (o *Output) Error(msg string, args ...any)

Error prints an error message with X mark.

func (*Output) Info

func (o *Output) Info(msg string, args ...any)

Info prints an info message.

func (*Output) Line

func (o *Output) Line(msg string, args ...any)

Line prints a plain message.

func (*Output) Print

func (o *Output) Print(data any) error

Print prints data in the configured format.

func (*Output) SetFormat

func (o *Output) SetFormat(format string) *Output

SetFormat sets the output format.

func (*Output) SetWriter

func (o *Output) SetWriter(w io.Writer) *Output

SetWriter sets the output writer.

func (*Output) Success

func (o *Output) Success(msg string, args ...any)

Success prints a success message with checkmark.

func (*Output) Warning

func (o *Output) Warning(msg string, args ...any)

Warning prints a warning message.

type OutputFlags

type OutputFlags struct {
	Format string // json, yaml, table, text
	Output string // output file path (empty for stdout)
}

OutputFlags holds flags for output formatting.

type RootConfig

type RootConfig struct {
	// Name is the binary name (e.g., "gz-git")
	Name string
	// Short is a short description
	Short string
	// Long is a long description
	Long string
	// Version string
	Version string
	// VersionTemplate customizes version output
	VersionTemplate string
}

RootConfig holds configuration for creating a root command.

type VersionInfo

type VersionInfo struct {
	Version   string
	GitCommit string
	BuildDate string
	GoVersion string
	Platform  string
}

VersionInfo holds extended version information.

func (VersionInfo) Short

func (v VersionInfo) Short() string

Short returns just the version string.

func (VersionInfo) String

func (v VersionInfo) String() string

String returns a formatted version string.

Jump to

Keyboard shortcuts

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