Documentation
¶
Overview ¶
Package cli provides CLI utilities for gzh-cli tools.
Index ¶
- func AddConfirmFlags(cmd *cobra.Command, flags *ConfirmFlags)
- func AddDryRunFlags(cmd *cobra.Command, flags *DryRunFlags)
- func AddGlobalFlags(cmd *cobra.Command, flags *GlobalFlags)
- func AddOutputFlags(cmd *cobra.Command, flags *OutputFlags)
- func AddVersionCmd(root *cobra.Command, info VersionInfo)
- func DryRun()
- func Error(msg string, args ...any)
- func Execute(cmd *cobra.Command)
- func ExecuteWithCode(cmd *cobra.Command) int
- func Info(msg string, args ...any)
- func NewRootCmd(cfg RootConfig) *cobra.Command
- func Success(msg string, args ...any)
- func Warning(msg string, args ...any)
- type ConfirmFlags
- type DryRunFlags
- type GlobalFlags
- type Output
- func (o *Output) DryRun()
- func (o *Output) Error(msg string, args ...any)
- func (o *Output) Info(msg string, args ...any)
- func (o *Output) Line(msg string, args ...any)
- func (o *Output) Print(data any) error
- func (o *Output) SetFormat(format string) *Output
- func (o *Output) SetWriter(w io.Writer) *Output
- func (o *Output) Success(msg string, args ...any)
- func (o *Output) Warning(msg string, args ...any)
- type OutputFlags
- type RootConfig
- type VersionInfo
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 ExecuteWithCode ¶
ExecuteWithCode runs the root command and returns the exit code.
func NewRootCmd ¶
func NewRootCmd(cfg RootConfig) *cobra.Command
NewRootCmd creates a new root command with standard configuration.
Types ¶
type ConfirmFlags ¶
type ConfirmFlags struct {
Yes bool
}
ConfirmFlags holds flags for confirmation prompts.
type DryRunFlags ¶
DryRunFlags holds flags for dry-run mode.
type GlobalFlags ¶
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.
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.