package cmdos
import "codeberg.org/roble/cmdos"
package cmdos is a library for creating CLIs.
Index ¶
- func ArgDefault(val string) flagArg
- func ArgRequire() flagArg
- func Run(c Command, args []string) error
- func WriteHelp(w io.Writer, c Command) error
- type Command
- type Flag
- type HelpTemplate
- type Info
- type Subcommands
- type Values
Functions ¶
func ArgDefault ¶
func ArgDefault(val string) flagArg
ArgDefault can be used when you want to give a flag a default value.
func ArgRequire ¶
func ArgRequire() flagArg
ArgRequire can be used to force the user to set a flag on a command.
func Run ¶
Run is the main entry point for a cmdos CLI.
func WriteHelp ¶
WriteHelp writes the help info from a Command to a io.Writer.
Types ¶
type Command ¶
Command is an interface for creating a CLI command.
type Flag ¶
Flag holds info to define a flag on a command.
type HelpTemplate ¶
type HelpTemplate interface { HelpTemplate() string }
HelpTemplate is an optional interface. Implement this method to use a custom template to generate help text.
type Info ¶
Info contains info about the command we're defining.
type Subcommands ¶
type Subcommands interface { Subcommands() []Command }
Subcommands is an optional interface. Implement this method to register subcommands on a Command.
type Values ¶
type Values struct {
// contains filtered or unexported fields
}
Values gives you access to flag values.
func (*Values) Args ¶
Args returns the arguments passed to a command.
func (*Values) Count ¶
Count returns the amount of times a flag was set.
func (*Values) Decode ¶
Decode unmarshals flag values into a dst struct. The dst struct should tag its fields. The tag value should match the name of the flag.
Help bool `cmdos:"help"` Addr string `cmdos:"addr"`
func (*Values) Has ¶
Has returns whether a flag was set or not.
Source Files ¶
command.go flag.go help.go run.go values.go
- Version
- v0.0.0-20250511070247-987e74490f10 (latest)
- Published
- May 11, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 months ago –
Tools for package owners.