Documentation
¶
Overview ¶
package star is a library for making command line applications
Index ¶
- func Main(c Command)
- func OSEnv(prefix string) map[string]string
- func ParseFlags(dst map[Symbol][]any, flags []IParam, args []string) (rest []string, err error)
- func ParsePos(dst map[Symbol][]any, params []IParam, args []string) (rest []string, err error)
- func ParseString(x string) (string, error)
- func Ptr[T any](x T) *T
- func Run(ctx context.Context, cmd Command, env map[string]string, calledAs string, ...) error
- type Command
- type Context
- type IParam
- type Metadata
- type Param
- type Symbol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
func Main(c Command)
Main is a default entrypoint for a Command. e.g.
func main() { star.Main(yourCommandHere) }
func ParseFlags ¶
ParseFlags takes a slice of args, and parses paramaeters in the list of flags. ParseFlags writes values to dst.
func ParseString ¶
ParseString is a parser for strings, it is the identity function on strings, and never errors.
Types ¶
type Context ¶
type Context struct { context.Context Params map[Symbol][]any Env map[string]string StdIn *bufio.Reader StdOut *bufio.Writer StdErr *bufio.Writer CalledAs string Extra []string // contains filtered or unexported fields }
Context is the context in which a command is run. It provides parsed parameters, input and output streams, and a go context.Context
type Param ¶
type Param[T any] struct { // Name identifies the parameter Name Symbol // Default is used as input to Parse if the parameter was not specified Default *string // Repeated means the parameter can be specified multiple times Repeated bool // Parse is called to convert strings Parse func(string) (T, error) }
Click to show internal directories.
Click to hide internal directories.