scli

package
v0.5.16 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCfg

type BaseCfg struct {
	//Name is the command full name
	Name string
	//Short is the command aliases name
	Short string
	//Usage is the description of command
	Usage string
	//Required means this flag must be set
	Required bool
}

type Cmd

type Cmd interface {
	//Init will construct command line parser with options
	Init(options ...Option) error
	//Parse will parse so.args
	Parse([]string) error
	//GetString will get string flag from cli context
	GetString(string) string
	//GetBool will get bool flag from cli context
	GetBool(string) bool
	//GetNumber will get number flag from cli context
	GetNumber(string) int
}

Cmd is box's command line parser

func NewCmd

func NewCmd(opts ...Option) Cmd

type CommandCfg

type CommandCfg struct {
	*BaseCfg
	Action func([]string) error
}

CommandCfg is the config of command

type FlagCfg

type FlagCfg struct {
	*BaseCfg
	//Default value
	Default string
	//Dest is pointer of value
	Dest interface{}
}

FlagCfg is the config of parameter

type Option

type Option func(options *Options)

func WithCommand

func WithCommand(command *CommandCfg) Option

func WithFlag

func WithFlag(flag *FlagCfg) Option

func WithStringFlag

func WithStringFlag(flag *FlagCfg) Option

WithStringFlag will create string flag

type Options

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

Jump to

Keyboard shortcuts

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