cli

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cli provides CLI scaffolding utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddStandardFlags

func AddStandardFlags(cmd *cobra.Command, flags *StandardFlags)

AddStandardFlags adds standard flags to a cobra command.

func NewCommand

func NewCommand(name, short string, runFunc RunFunc) *cobra.Command

NewCommand creates a cobra command with standard flags.

Types

type CommandBuilder

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

CommandBuilder helps build cobra commands with standard patterns.

func NewCommandBuilder

func NewCommandBuilder(name, short string) *CommandBuilder

NewCommandBuilder creates a new command builder.

func (*CommandBuilder) Build

func (b *CommandBuilder) Build() *cobra.Command

Build creates the cobra command.

func (*CommandBuilder) GetFlags

func (b *CommandBuilder) GetFlags() *StandardFlags

GetFlags returns the standard flags.

func (*CommandBuilder) WithLong

func (b *CommandBuilder) WithLong(long string) *CommandBuilder

WithLong sets the long description.

func (*CommandBuilder) WithRun

func (b *CommandBuilder) WithRun(run RunFunc) *CommandBuilder

WithRun sets the run function.

type InputSource

type InputSource int

InputSource represents where input comes from.

const (
	// InputSourceArgs indicates input from command-line arguments.
	InputSourceArgs InputSource = iota

	// InputSourceStdin indicates input from stdin.
	InputSourceStdin

	// InputSourceFile indicates input from a file.
	InputSourceFile
)

func ResolveInput

func ResolveInput(args []string, stdinFile string) (string, InputSource, error)

ResolveInput resolves input from args, stdin, or file. Priority: args > stdin > file

type RunFunc

type RunFunc func(cmd *cobra.Command, args []string) error

RunFunc is the function signature for command execution.

type StandardFlags

type StandardFlags struct {
	Model    string
	Output   string
	Format   string
	Verbose  bool
	APIKey   string
	BaseURL  string
	Provider string
}

StandardFlags represents common CLI flags.

Jump to

Keyboard shortcuts

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