cli

package
v0.0.0-...-0c9055a Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package cli handles all of the core command line parsing. It's the first entry point after the real main function, and it imports and runs our core "lib".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLI

func CLI(ctx context.Context, data *cliUtil.Data) error

CLI is the entry point for using mgmt normally from the CLI.

func NormalizeArgs

func NormalizeArgs(args []string) []string

NormalizeArgs adjusts some of the cli options before go-arg parses it. The parser supports string options and bool options, but not optional string values. This substitutes in empty values for those options.

Types

type Args

type Args struct {
	License bool `arg:"--license" help:"display the license and exit"`

	RunCmd *RunArgs `arg:"subcommand:run" help:"run code on this machine"`

	DeployCmd *DeployArgs `arg:"subcommand:deploy" help:"deploy code into a cluster"`

	SetupCmd *SetupArgs `arg:"subcommand:setup" help:"setup some bootstrapping tasks"`

	FirstbootCmd *FirstbootArgs `arg:"subcommand:firstboot" help:"run some tasks on first boot"`

	DocsCmd *DocsGenerateArgs `arg:"subcommand:docs" help:"generate documentation"`

	ToolsCmd *ToolsArgs `arg:"subcommand:tools" help:"collection of useful tools"`

	// This never runs, it gets preempted in the real main() function.
	// XXX: Can we do it nicely with the new arg parser? can it ignore all args?
	EtcdCmd *EtcdArgs `arg:"subcommand:etcd" help:"run standalone etcd"`

	// This never runs, it gets preempted in the real main() function.
	ProvisionerCmd *ProvisionerArgs `arg:"subcommand:provisioner" help:"provision bare metal machines"`
	// contains filtered or unexported fields
}

Args is the CLI parsing structure and type of the parsed result. This particular struct is the top-most one.

func (*Args) Description

func (obj *Args) Description() string

Description returns a description string. Implementing this signature is part of the API for the cli library.

func (*Args) Run

func (obj *Args) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates.

func (*Args) Version

func (obj *Args) Version() string

Version returns the version string. Implementing this signature is part of the API for the cli library.

type DeployArgs

type DeployArgs struct {
	// SSHURL can be specified if we want to transport the SSH client
	// connection over SSH. If this is specified, the second hop is made
	// with the Seeds values, but they connect from this destination. You
	// can specify this in the standard james@server:22 format. This will
	// use your ~/.ssh/ directory for public key authentication and
	// verifying the host key in the known_hosts file. This must already be
	// setup for things to work.
	SSHURL string `arg:"--ssh-url" help:"transport the etcd client connection over SSH to this server"`

	// SSHHostKey is the key part (which is already base64 encoded) from a
	// known_hosts file, representing the host we're connecting to. If this
	// is specified, then it overrides looking for it in the URL.
	SSHHostKey string `arg:"--ssh-hostkey" help:"use this ssh known hosts key when connecting over SSH"`

	Seeds []string `arg:"--seeds,separate,env:MGMT_SEEDS" help:"default etcd client endpoints"`
	Noop  bool     `arg:"--noop" help:"globally force all resources into no-op mode"`
	Sema  int      `arg:"--sema" default:"-1" help:"globally add a semaphore to all resources with this lock count"`
	NoGit bool     `arg:"--no-git" help:"don't look at git commit id for safe deploys"`
	Force bool     `arg:"--force" help:"force a new deploy, even if the safety chain would break"`

	NoAutoEdges bool `arg:"--no-autoedges" help:"skip the autoedges stage"`
	NoAutoGroup bool `arg:"--no-autogroup" help:"skip the autogroup stage"`

	DeployEmpty      *cliUtil.EmptyArgs      `arg:"subcommand:empty" help:"deploy empty payload"`
	DeployLang       *cliUtil.LangArgs       `arg:"subcommand:lang" help:"deploy lang (mcl) payload"`
	DeployYaml       *cliUtil.YamlArgs       `arg:"subcommand:yaml" help:"deploy yaml graph payload"`
	DeployPuppet     *cliUtil.PuppetArgs     `arg:"subcommand:puppet" help:"deploy puppet graph payload"`
	DeployLangPuppet *cliUtil.LangPuppetArgs `arg:"subcommand:langpuppet" help:"deploy langpuppet graph payload"`
}

DeployArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `deploy` subcommand which all frontends can use.

func (*DeployArgs) Run

func (obj *DeployArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates. This particular Run is the run for the main `deploy` subcommand. This always requires a frontend to deploy to the cluster, but if you don't want a graph, you can use the `empty` frontend. The engine backend is agnostic to which frontend is deployed, in fact, you can deploy with multiple different frontends, one after another, on the same engine.

type DocsGenerateArgs

type DocsGenerateArgs struct {
	docs.Config // embedded config (can't be a pointer) https://github.com/alexflint/go-arg/issues/240

	DocsGenerate *cliUtil.DocsGenerateArgs `arg:"subcommand:generate" help:"generate documentation"`
}

DocsGenerateArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `docs generate` subcommand.

func (*DocsGenerateArgs) Run

func (obj *DocsGenerateArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates. This particular Run is the run for the main `docs` subcommand.

type EtcdArgs

type EtcdArgs struct{}

EtcdArgs is the CLI parsing structure and type of the parsed result. This particular one is empty because the `etcd` subcommand is preempted in the real main() function.

type FirstbootArgs

type FirstbootArgs struct {
	firstboot.Config // embedded config (can't be a pointer) https://github.com/alexflint/go-arg/issues/240

	FirstbootStart *cliUtil.FirstbootStartArgs `arg:"subcommand:start" help:"start firstboot service"`
}

FirstbootArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `firstboot` subcommand.

func (*FirstbootArgs) Run

func (obj *FirstbootArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates. This particular Run is the run for the main `firstboot` subcommand. The firstboot command as a service that lets you run commands once on the first boot of a system.

type ProvisionerArgs

type ProvisionerArgs struct{}

ProvisionerArgs is the CLI parsing structure and type of the parsed result. This particular one is empty because the `provisioner` subcommand is preempted in the real main() function via the entry package.

type RunArgs

type RunArgs struct {
	lib.Config // embedded config (can't be a pointer) https://github.com/alexflint/go-arg/issues/240

	RunEmpty      *cliUtil.EmptyArgs      `arg:"subcommand:empty" help:"run empty payload"`
	RunLang       *cliUtil.LangArgs       `arg:"subcommand:lang" help:"run lang (mcl) payload"`
	RunYaml       *cliUtil.YamlArgs       `arg:"subcommand:yaml" help:"run yaml graph payload"`
	RunPuppet     *cliUtil.PuppetArgs     `arg:"subcommand:puppet" help:"run puppet graph payload"`
	RunLangPuppet *cliUtil.LangPuppetArgs `arg:"subcommand:langpuppet" help:"run a combined lang/puppet graph payload"`
}

RunArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `run` subcommand which all frontends can use.

func (*RunArgs) Run

func (obj *RunArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates. This particular Run is the run for the main `run` subcommand. This always requires a frontend to start the engine, but if you don't want a graph, you can use the `empty` frontend. The engine backend is agnostic to which frontend is running, in fact, you can deploy with multiple different frontends, one after another, on the same engine.

type SetupArgs

type SetupArgs struct {
	setup.Config // embedded config (can't be a pointer) https://github.com/alexflint/go-arg/issues/240

	SetupPkg       *cliUtil.SetupPkgArgs       `arg:"subcommand:pkg" help:"setup packages"`
	SetupSvc       *cliUtil.SetupSvcArgs       `arg:"subcommand:svc" help:"setup services"`
	SetupFirstboot *cliUtil.SetupFirstbootArgs `arg:"subcommand:firstboot" help:"setup firstboot"`
}

SetupArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `setup` subcommand.

func (*SetupArgs) Run

func (obj *SetupArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates. This particular Run is the run for the main `setup` subcommand. The setup command does some bootstrap work to help get things going.

type ToolsArgs

type ToolsArgs struct {
	tools.Config // embedded config (can't be a pointer) https://github.com/alexflint/go-arg/issues/240

	ToolsGrow *cliUtil.ToolsGrowArgs `arg:"subcommand:grow" help:"tools for growing storage"`
}

ToolsArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `tools` subcommand.

func (*ToolsArgs) Run

func (obj *ToolsArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error)

Run executes the correct subcommand. It errors if there's ever an error. It returns true if we did activate one of the subcommands. It returns false if we did not. This information is used so that the top-level parser can return usage or help information if no subcommand activates. This particular Run is the run for the main `tools` subcommand. The tools command provides some functionality which can be helpful with provisioning and config management.

Directories

Path Synopsis
Package util has some CLI related utility code.
Package util has some CLI related utility code.

Jump to

Keyboard shortcuts

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