cli

package
v0.0.0-...-5ffab81 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2013 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cli provides an advanced CLI framework.

Commands are defined as structs wich must be registerd with Register(T).

type Command struct {
  // The parent command must always be present and the first field
  // It defaults to cli.Root ban it can be any command type.
  cli.Root

  // The name of the command as it was passed to exec()
  cli.Arg0

  // flag: env: and arg can be combined
  Field Type `flag:"-f,--flag"`
  Field Type `env:"VAR"`
  Field Type `arg`

  // The manual for this command
  cli.Manual `
    Usage:   a usage example
    Summary: a short decription of the command

    .Field:
      A description for the field Field.

    Section:
      A manual section and header.
  `
}

func init() {
  // register the command. (must happen during init())
  cli.Register(Command{})
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main

func Main(args []string, environ []string)

func Register

func Register(v interface{})

func RegisterType

func RegisterType(t reflect.Type)

Types

type Arg0

type Arg0 string

type Command

type Command interface {
	Main() error
}

type Manual

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

func (*Manual) Open

func (m *Manual) Open()

type Root

type Root struct {
	Help bool `flag:"-h,--help"`

	Manual `

    .Help:
      Show the help message for the current command.

  `
}

Jump to

Keyboard shortcuts

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