commands

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ShortUsage = "A CLI application showing various ways to declare positional/flags/commands with structs and fields."
	LongUsage  = `` /* 465-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func AddCommandsLongHelp

func AddCommandsLongHelp(root *cobra.Command)

AddCommandsLongHelp adds long help messages to our newly generated commands.

Types

type Root

type Root struct {
	//
	// Positional arguments commands -------------------------------------------------
	//
	// These commands demonstrate how to declare positional arguments and their
	// associated functionality (requirements, completions, validations, etc)
	//
	// First remarks:
	// - The commands are registered individually, but each is tagged with a group (eg, they are not grouped in a struct)
	args.MultipleListsArgs  `` /* 138-byte string literal not displayed */
	args.FirstListArgs      `` /* 127-byte string literal not displayed */
	args.MultipleMinMaxArgs `` /* 132-byte string literal not displayed */
	args.TagCompletedArgs   `command:"tag-completed" description:"Specify completers with struct tags" group:"positionals"`
	args.RestSliceMax       `` /* 132-byte string literal not displayed */

	//
	// Flags commands ----------------------------------------------------------------
	//
	// These commands demonstrate how to declare command flags and their
	// associated functionality (requirements, completions, validations, etc)
	//
	// First remarks:
	// - As with the 'positionals' commands above, each of these command is embedded individually, and each is tagged with its group name.
	opts.BasicOptions   `command:"basic" alias:"ba" desc:"Shows how to use some basic flags (shows option stacking, and maps)" group:"flags"`
	opts.IgnoredOptions `` /* 135-byte string literal not displayed */
	opts.DefaultOptions `command:"defaults" desc:"Contains flags with default values, and others with validated choices" group:"flags"`

	// Validated args/flags ----------------------------------------------------------
	//
	// The following struct demonstrates how to group commands within a struct.
	// This allows to print them under a given heading in the documentation/usage,
	// and optionally to separate your command groups by package/type.
	validated.Commands `commands:"validated"`
}

Root is the root command of our application, and encapsulates all of the application subcommands as embedded structs.

Jump to

Keyboard shortcuts

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