cli

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Standard streams, redirected for testing.
	Stdin  io.Reader = os.Stdin
	Stdout io.Writer = os.Stdout
	Stderr io.Writer = os.Stderr
	// overridden for testing
	ReadPassword = term.ReadPassword
)
View Source
var (
	HelpHeader = strings.TrimSpace(`
{{.DisplayName}} lets you control services and perform management actions on
the system that is running them.
`)

	HelpFooter = strings.TrimSpace(`
Set the PEBBLE environment variable to override the configuration directory
(which defaults to {{.DefaultDir}}). Set PEBBLE_SOCKET to override
the unix socket used for the API (defaults to $PEBBLE/.pebble.socket).
`)
)
View Source
var ErrExtraArgs = fmt.Errorf("too many arguments for command")

ErrExtraArgs is returned if extra arguments to a command are found

View Source
var HelpCategories = []HelpCategory{{
	Label:       "Run",
	Description: "run the service manager",
	Commands:    []string{"run"},
}, {
	Label:       "Info",
	Description: "help and version information",
	Commands:    []string{"help", "version"},
}, {
	Label:       "Plan",
	Description: "view and change configuration",
	Commands:    []string{"add", "plan"},
}, {
	Label:       "Services",
	Description: "manage services",
	Commands:    []string{"services", "logs", "start", "restart", "signal", "stop", "replan"},
}, {
	Label:       "Checks",
	Description: "manage health checks",
	Commands:    []string{"checks", "health"},
}, {
	Label:       "Files",
	Description: "work with files and execute commands",
	Commands:    []string{"push", "pull", "ls", "mkdir", "rm", "exec"},
}, {
	Label:       "Changes",
	Description: "manage changes and their tasks",
	Commands:    []string{"changes", "tasks"},
}, {
	Label:       "Notices",
	Description: "manage notices and warnings",
	Commands:    []string{"warnings", "okay", "notices", "notice", "notify"},
}}

HelpCategories helps us by grouping commands

Functions

func AddCommand

func AddCommand(info *CmdInfo)

AddCommand adds a command to the top-level parser.

func Parser

func Parser(opts *ParserOptions) *flags.Parser

Parser creates and populates a fresh parser. Since commands have local state a fresh parser is required to isolate tests from each other.

func Run

func Run(options *RunOptions) error

func Wait added in v1.9.0

func Wait(cli *client.Client, changeID string) (*client.Change, error)

Wait polls the progress of a change and displays a progress bar.

This function blocks until the change is done or fails. If the change has numeric progress information, the information is displayed as a progress bar.

Types

type CmdInfo

type CmdInfo struct {
	// Name of the command
	Name string

	// Summary is a single-line help string that will be displayed
	// in the full Pebble help manual (i.e. help --all)
	Summary string

	// Description contains exhaustive documentation about the command,
	// that will be reflected in the specific help manual for the
	// command, and in the Pebble man page.
	Description string

	// New is a function that creates a new instance of the command.
	New func(*CmdOptions) flags.Commander

	// ArgsHelp (optional) contains help about the command-line arguments
	// (including options) supported by the command.
	//
	//  map[string]string{
	//      "--long-option": "my very long option",
	//      "-v": "verbose output",
	//      "<change-id>": "named positional argument"
	//  }
	ArgsHelp map[string]string

	// Whether to pass all arguments after the first non-option as remaining
	// command line arguments. This is equivalent to strict POSIX processing.
	PassAfterNonOption bool

	// When set, the command will be a subcommand of the `debug` command.
	Debug bool
}

CmdInfo holds information needed by the CLI to execute commands and populate entries in the help manual.

type CmdOptions

type CmdOptions struct {
	Client     *client.Client
	Parser     *flags.Parser
	PebbleDir  string
	SocketPath string
}

CmdOptions exposes state made accessible during command execution.

type HelpCategory

type HelpCategory struct {
	Label       string
	Description string
	Commands    []string
}

type ParserOptions added in v1.10.0

type ParserOptions struct {
	Client     *client.Client
	PebbleDir  string
	SocketPath string
}

type RunOptions added in v1.10.0

type RunOptions struct {
	// when starting a daemon ("pebble run"), the ClientConfig.Socket value
	// is also used as the Unix domain socket path for the listening socket
	ClientConfig *client.Config
	Logger       logger.Logger
	PebbleDir    string
}

Jump to

Keyboard shortcuts

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