command

package
v0.0.0-...-7d4a354 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name        = "Agricola"
	CommandName = "ager"
)
View Source
const (
	ExitSuccess         = 0
	ExitInvalidArgs     = 2
	ExitCommandNotFound = 4
)

Variables

This section is empty.

Functions

func DefaultFlagSet

func DefaultFlagSet(n string) *flag.FlagSet

Types

type Command

type Command struct {
	// Run runs the command.
	// The args are the arguments passed in after the command name.
	// The function returns the exit code of the command.
	Run func(cmd *Command, args []string) int

	// UsageLine is the one-line usage message.
	// The words between "ager" and the first flag or argument in the line are
	// taken to be the command name.
	UsageLine string

	// Short is the short description shown in the "ager help" output.
	Short string

	// Long is the long message shown in the "ager help <this-command>" output.
	Long string

	// Flag is a set of flags specific to this command.
	Flag *flag.FlagSet

	// Commands is a list of the available commands (so-called subcommands) and
	// other help topics for this command.
	// The order here is the order in which they are printed when running the
	// 'help' command.
	Commands []*Command
}

A Command is an implementation of an Agricola command.

func BaseCommand

func BaseCommand() *Command

func (*Command) LongName

func (c *Command) LongName() string

LongName returns the command's long name. Command's long name is the string between "ager" and the first arguments.

func (*Command) Lookup

func (c *Command) Lookup(n string) *Command

Lookup returns the subcommand with the given name, if any. Otherwise it returns nil. Lookup ignores subcommands that have len(c.Commands) == 0 and c.Run == nil. Such subcommands are only meant to be used as arguments to "help".

func (*Command) Name

func (c *Command) Name() string

Name return the command's short name. The short name of a command is the last word in the usage line before a flag or an argument.

func (*Command) Runnable

func (c *Command) Runnable() bool

Runnable reports whether the command can be run. If not, it is a pseudo-command used for printing help.

func (*Command) Usage

func (c *Command) Usage()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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