cli

package
v0.0.0-...-2c249d0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2014 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cli is a library to help creating command line tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	Definition() string // usually it's the output for --help
	Exec(args []string) error
}

To add a module, implement this interface. Definition is the command definition. Exec is the behaviour that you want to implement as a command

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module is the shared structure of commands and sub-commands.

func NewCLI

func NewCLI() *Module

NewCLI returns a root Module that you can add commands and another modules (sub-commands).

func (*Module) AddCommand

func (m *Module) AddCommand(name string, command Command)

AddCommand adds a new command this module.

func (*Module) AddSubCommand

func (m *Module) AddSubCommand(name string) *Module

AddSubCommand adds a new sub-command this module.

func (*Module) Definition

func (m *Module) Definition() string

func (*Module) Exec

func (m *Module) Exec(args []string) error

func (*Module) Run

func (m *Module) Run()

Run is the function that is intended to be run from main().

Jump to

Keyboard shortcuts

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