cli

package
v0.0.0-...-d2acac8 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package cli provides a bare bones CLI with commands.

cli supports standard Go flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App []Command

An App is composed of many commands.

func (App) Help

func (a App) Help() string

Help returns the app's help string.

func (App) Run

func (a App) Run(args []string)

Run runs the app. Expects program name as the first arg, and an optional command name next.

type Command

type Command struct {
	// Name or Aliases are used to match argv[1] and select this command.
	Name    string
	Aliases []string

	// Short is a one-line description for the command.
	Short string

	// Run is called if argv[1] matches the command. Flags are parsed before Run is called.
	Run func(args []string)
	// contains filtered or unexported fields
}

Command is a CLI command.

func (*Command) Flags

func (c *Command) Flags() *flag.FlagSet

Flags returns a modifiable flag set for this command.

If argv[1] matches this command, these flags will be parsed.

Jump to

Keyboard shortcuts

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