cmdapp

package
v0.0.0-...-616f46f Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2016 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package cmdapp implements a command line application that host a set of commands as in the go tool or git.

Index

Constants

View Source
const (
	ExitOk   = iota // success
	ExitErr         // any processing error
	ExitArgs        // invalid arguments
	ExitIn          // error while reading input
	ExitOut         // error while writing output
)

Common exit codes.

Variables

View Source
var Commands []*Command

Commands is the list of available commands and help topics. The order in the list is used for help output.

View Source
var Short string

Short is a short description of the application.

Functions

func Name

func Name() string

Name returns the application's name, from the argument list.

func Run

func Run()

Run runs the application.

Types

type Command

type Command struct {
	// Run runs the command.
	// The argument list is the set of arguments unparsed by flag
	// package.
	Run func(c *Command, args []string)

	// UsageLine is the usage message.
	// The first word in the line is taken to be the command name.
	UsageLine string

	// Short is a short description of the command.
	Short string

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

	// Flag is the set of flags specific to this command.
	Flag flag.FlagSet
}

A Command is an implementation of a hosted command.

func (*Command) Name

func (c *Command) Name() string

Name returns the command's name: the first word in the usage line.

func (*Command) Usage

func (c *Command) Usage()

Usage prints the usage message and exits the program.

Jump to

Keyboard shortcuts

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