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 ¶
- func CLI(ctx context.Context, data *cliUtil.Data) (reterr error)
- func NormalizeArgs(args []string) []string
- type Args
- type CheckArgs
- type CheckLangArgs
- type DeployArgs
- type DocsGenerateArgs
- type EtcdArgs
- type FirstbootArgs
- type FmtArgs
- type HelpArgs
- type ProvisionerArgs
- type RunArgs
- type SetupArgs
- type ToolsArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeArgs ¶
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"`
HelpCmd *HelpArgs `arg:"subcommand:help" help:"display this help and exit"`
FmtCmd *FmtArgs `arg:"subcommand:fmt" help:"format mcl code"`
CheckCmd *CheckArgs `arg:"subcommand:check" help:"check code on this machine"`
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 ¶
Description returns a description string. Implementing this signature is part of the API for the cli library.
func (*Args) Run ¶
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.
type CheckArgs ¶
type CheckArgs struct {
lib.Config // embedded config (can't be a pointer) https://github.com/alexflint/go-arg/issues/240
CheckLang *CheckLangArgs `arg:"subcommand:lang" help:"check lang (mcl) payload"`
}
CheckArgs RunArgs is the CLI parsing structure and type of the parsed result. This particular one contains all the common flags for the `check` subcommand.
func (*CheckArgs) Run ¶
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 `check` subcommand. The check command allows validation of mcl files.
type CheckLangArgs ¶
type CheckLangArgs struct {
// Input is the input mcl code or file path or any input specification.
Input string `arg:"positional,required"`
Download bool `arg:"--download" help:"download any missing imports"`
Update bool `arg:"--update" help:"update all dependencies to the latest versions"`
// SkipUnify specifies that the mcl unification check should be skipped.
// It is used by the check command, which enables that check by default.
SkipUnify bool `arg:"--skip-unify" help:"skip the mcl type unification"`
UnifySolver *string `arg:"--unify-name" help:"pick a specific unification solver"`
UnifyOptimizations []string `arg:"--unify-optimizations,separate" help:"list of unification optimizations to request (experts only)"`
// SkipFmt specifies that the mcl format check should be skipped. It is
// used by the check command, which enables that check by default.
SkipFmt bool `arg:"--skip-fmt" help:"skip the mcl format check"`
Depth int `arg:"--depth" default:"-1" help:"max recursion depth limit (-1 is unlimited)"`
// The default of 0 means any error is a failure by default.
Retry int `arg:"--retry" help:"max number of retries (-1 is unlimited)"`
ModulePath string `arg:"--module-path,env:MGMT_MODULE_PATH" help:"choose the modules path (absolute)"`
}
CheckLangArgs is the check lang CLI parsing structure and type of the parsed result.
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"`
// SSHID is the private key path for SSH client auth with --ssh-url. If
// empty, mgmt scans the default SSH directory for id_* private keys.
SSHID string `arg:"--ssh-id" help:"private key for SSH client auth"`
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"`
}
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 ¶
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 ¶
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 ¶
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 FmtArgs ¶
type FmtArgs struct {
Test bool `arg:"-t,--test" help:"return non-zero if not formatted correctly"`
Verbose bool `arg:"-v,--verbose" help:"print logs of the common operations"`
// Input is the input mcl code or file path or any input specification.
Input string `arg:"positional"`
}
FmtArgs is the CLI parsing structure and type of the parsed result. This particular one contains the flags for the `fmt` subcommand. This command recursively formats files by descending through the filesystem hierarchy. This is in contrast to the `check` subcommand which examines various aspects by traversing the AST. By default this command always formats. This makes it ergonomic to run `mgmt check` in your source dir and have everything fixed without needing a `Makefile` wrapper like golang needs for `gofmt`. Without an input param it starts in the current working directory. If you specify a file it will only format that. If you specify a directory it will descend into that. If you use the `--test` arg, it only checks and doesn't write. It returns 0 if everything is correctly formatted, otherwise non-zero.
func (*FmtArgs) Description ¶
Description returns a description string. Implementing this signature is part of the API for the cli library. XXX: Is this used by the go-arg cli library?
type HelpArgs ¶
type HelpArgs struct{}
HelpArgs is the CLI parsing structure and type of the parsed result. This particular one displays the same top-level help that bare `mgmt` does.
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"`
}
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 ¶
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 ¶
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 ¶
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.