cmd

package
v0.0.0-...-4d5f9bd Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdList

func CmdList(cmds map[string]Command)

func CmdListToArray

func CmdListToArray(cmds map[string]Command) []string

func GetGitCommit

func GetGitCommit() string

Helper method that returns the git commit hash

Types

type Command

type Command struct {
	Func        func(progname string, args []string)
	Help        string
	Usage       string
	Example     string
	Subcommands map[string]Command
	ArgValidate func(args []string) error
}

func FindCommandByArgs

func FindCommandByArgs(cmds map[string]Command, args []string) (*Command, []string, error)

func (*Command) GetUsage

func (c *Command) GetUsage() string

func (*Command) Validate

func (c *Command) Validate(args []string) error

type CommandLineState

type CommandLineState struct {
	// The map of commands
	Commands map[string]Command

	// The function that returns the header (program name, version, etc.)
	GetHeader func() string
}

A struct that holds the state of the command line

func (*CommandLineState) Run

func (s *CommandLineState) Run()

Jump to

Keyboard shortcuts

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