pclient

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCachedParam

func GetCachedParam(cachePath, key, prompt, layout string) string

func NormalizeLegacyLongFlagArgs

func NormalizeLegacyLongFlagArgs(args []string) []string

NormalizeLegacyLongFlagArgs converts legacy args style: -db -> --db Only handles "single dash + multiple chars" args, preserves short args like -l/-h

func RegParamToCobra

func RegParamToCobra(cmd *cobra.Command,
	specs []ParamItem) map[string]*string

RegParamToCobra registers parameters to cobra command cobra parses parameters and stores values in the returned map

func RunApp

func RunApp(cli func(), ui func())

RunApp is the platform-aware entrypoint - No args on Windows: runs UI mode - No args on non-Windows: runs CLI (interactive menu) - With args: always runs CLI mode

Types

type ParamItem

type ParamItem struct {
	Name    string
	Usage   string
	Default string
}

ParamItem defines a parameter specification

type ParamMap

type ParamMap map[string]string

ParamMap is a map of parameter values

func GetCachedParamMap

func GetCachedParamMap(
	cachePath string,
	cachePrefix string,
	specs []ParamItem,
) ParamMap

GetCachedParamMap interactively prompts user for parameter values with defaults Uses cached values from previous runs when available

func ParseParamFromCobra

func ParseParamFromCobra(flagRefs map[string]*string) ParamMap

ParseParamFromCobra extracts parameter values from cobra flag refs to ParamMap

type Tool

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

Tool provides unified CLI/Interactive/GUI tool execution

func NewTool

func NewTool(option ToolOption) *Tool

NewTool creates a new tool

func (*Tool) NewCobraCommand

func (x *Tool) NewCobraCommand() *cobra.Command

NewCobraCommand creates a cobra command for CLI mode

func (*Tool) RunCommand

func (x *Tool) RunCommand(args []string) error

RunCommand runs the tool with command-line arguments

func (*Tool) RunInteractive

func (x *Tool) RunInteractive()

RunInteractive runs the tool in interactive mode with cached parameters

type ToolOption

type ToolOption struct {
	ToolName       string
	Use            string
	Aliases        []string
	Short          string
	CacheKeyPrefix string
	ParamList      []ParamItem
	Run            func(values ParamMap) error

	// InteractiveHook allows additional interactive configuration beyond params
	InteractiveHook func(values ParamMap) ParamMap

	// CobraSetup allows additional cobra configuration
	CobraSetup func(cmd *cobra.Command) func(values ParamMap) ParamMap
}

ToolOption contains configuration for a tool entrypoint

Jump to

Keyboard shortcuts

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