cli

package
v0.0.0-...-22661af Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: GPL-3.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//Version is taken by the build flags, represent current version as
	//<major>.<minor>.<patch>
	Version string

	//Commit is the output of `git rev-parse HEAD` at the moment of the build
	Commit string

	//Build contains info about the scope of the build and should either be Debug or Release
	Build string = "Debug"
)
View Source
var WaptyCommands []*Cmd

WaptyCommands is the list of all wapty commands available. Each command `cmd` is invoked via `wapty cmd`

Functions

func AddCommand

func AddCommand(c *Cmd)

AddCommand allows packages to setup their own command. In order for them to be compiled, they must be imported by the main package with the "_" alias

func Init

func Init()

Init is the first function executed. It prints the banner and sets the default command.

func Printbanner

func Printbanner()

Printbanner prints the initial banner

Types

type Cmd

type Cmd struct {
	// Name is the name of the command. It's what comes after `wapty`.
	Name string

	// Run is the command entrypoint.
	Run func(...string)

	// UsageLine is the header of what's printed by flag.PrintDefaults.
	UsageLine string

	// Short is a one-line description of what the command does.
	Short string

	// Long is the detailed description of what the command does.
	Long string

	// Flag is the set of flags accepted by the command. This should be initialized in
	// the command's module's `init` function. The parsing of these flags is issued
	// by the main wapty entrypoint, so each command doesn't have to do it itself.
	Flag flag.FlagSet
}

Cmd is used by any package exposing a runnable command to gather information about command name, usage and flagset.

var DefaultCommand *Cmd

DefaultCommand is the prefixed command set at the beginning of execution

func FindCommand

func FindCommand(name string) (command *Cmd, err error)

FindCommand takes a string and searches for a command whose name has that string as prefix. If more than 1 command name has that string as a prefix (and no command name equals that string), an error is returned. If no suitable command is found, an error is returned.

func (*Cmd) Usage

func (c *Cmd) Usage()

Usage prints out the usage helper

Jump to

Keyboard shortcuts

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