jhanda

package module
v0.0.0-...-8de8eb9 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 8 Imported by: 12

README

Jhanda

Documentation

Flag parsing library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(receiver interface{}, args []string) ([]string, error)

Parse will populate the "receiver" object with the parsed values of the given "args". If the parser encounters a non-flag value, it will stop parsing and return the remainer of arguments. Parse will return an error in the case that the flags cannot be parsed, or a required flag is missing. The receiver is expected to be a pointer.

func PrintUsage

func PrintUsage(receiver interface{}) (string, error)

PrintUsage will return a string representation of the options provided by a Command flag set.

Types

type Command

type Command interface {
	Execute(args []string) error
	Usage() Usage
}

Command defines the interface for a command object type. For an object to be executable as a command, you will need to implement these methods.

type CommandSet

type CommandSet map[string]Command

CommandSet is a structural collection of executable commands referenced by a name. Use this object to translate the name of the command given at the commandline to an executable object to be invoked.

func (CommandSet) Execute

func (cs CommandSet) Execute(command string, args []string) error

Execute will invoke the Execute method of the Command that matches the name provided as "command", passing "args". Execute will return an error in the case that the command cannot be found by the given name.

func (CommandSet) Usage

func (cs CommandSet) Usage(command string) (Usage, error)

Usage will return the Usage object of the Command that matches the name provided as "command". Usage will return an error in the case that the command cannot be found by the given name.

type Usage

type Usage struct {
	Description      string
	ShortDescription string
	Flags            interface{}
}

Usage provides all of the details describing a Command, including a description, a shorter description (used when display a list of commands), and the flag options offered by the Command.

Directories

Path Synopsis
internal
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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