cli

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: Apache-2.0 Imports: 6 Imported by: 5

README

Build Status

cli

Utilities for creating complex CLI application in Go.

Documentation

Overview

Package cli provides base constructs to build complex command line applications.

By nesting components, one can build command line applications like: the go command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Passthrough

func Passthrough(ctx context.Context, comp *Component, args []string)

Passthrough is a implementation of the Run function that passes the execution through the sub commands

Types

type Component

type Component struct {
	// Components are the sub-components of the current component
	Components []*Component

	// Run runs the component
	// args are the arguments after the component name
	Run func(ctx context.Context, comp *Component, args []string)

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

	// Short is the short description of the component
	Short string

	// Long is the longer more detailed description of the component
	Long string
	// contains filtered or unexported fields
}

Component represents a command line component

func (*Component) FlagSet

func (c *Component) FlagSet() *flag.FlagSet

FlagSet returns the set of command line flags

func (*Component) Name

func (c *Component) Name() string

Name returns the name of the component: the first word in the UsageLine

func (*Component) Runnable

func (c *Component) Runnable() bool

Runnable returns whether this component is runnable or pure informational

func (*Component) SetOutput

func (c *Component) SetOutput(output io.Writer)

SetOutput sets the destination for usage messages. If output is nil, stderr is used

func (*Component) Usage

func (c *Component) Usage()

Usage prints out the usage information

Jump to

Keyboard shortcuts

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