cmd

package
v3.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cmd is an interface for building a command line binary

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd interface {
	// Init initialises options
	// Note: Use Run to parse command line
	Init(opts ...Option) error
	// Options set within this command
	Options() Options
	// The cli app within this cmd
	App() *cli.App
	// Run executes the command
	Run() error
	// Implementation
	String() string
}

TODO: replace App with RegisterCommand/RegisterFlags

type Option

type Option func(o *Options)

func Action

func Action(a func(*cli.Context) error) Option

Action to execute

func Commands

func Commands(c ...*cli.Command) Option

Commands to add

func Description

func Description(d string) Option

Command line Description

func Flags

func Flags(f ...cli.Flag) Option

Flags to add

func Name

func Name(n string) Option

Command line Name

func Version

func Version(v string) Option

Command line Version

type Options

type Options struct {
	// Name of the application
	Name string
	// Description of the application
	Description string
	// Version of the application
	Version string
	// Action to execute when Run is called and there is no subcommand
	// TODO replace with a build in context
	Action func(*cli.Context) error
	// TODO replace with built in command definition
	Commands []*cli.Command
	// TODO replace with built in flags definition
	Flags []cli.Flag
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

Directories

Path Synopsis
Package cli is a urfave/cli implementation of the command
Package cli is a urfave/cli implementation of the command

Jump to

Keyboard shortcuts

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