Documentation ¶
Overview ¶
Package cmd contains all the main commands for the `geneos` program
Index ¶
- Constants
- Variables
- func AddInstance(ct *geneos.Component, addCmdExtras instance.ExtraConfigValues, items []string, ...) (err error)
- func CmdArgs(command *cobra.Command) (ct *geneos.Component, args []string)
- func CmdArgsParams(command *cobra.Command) (ct *geneos.Component, args, params []string)
- func CommandPS(ct *geneos.Component, args []string, params []string) (err error)
- func Execute()
- func ImportFiles(ct *geneos.Component, args []string, sources []string) (err error)
- func RunE(root *cobra.Command, path []string, args []string) (err error)
- func Set(ct *geneos.Component, args, params []string) error
- func Start(ct *geneos.Component, watchlogs bool, args []string, params []string) (err error)
Constants ¶
const ( CommandGroupConfig = "config" CommandGroupComponents = "components" CommandGroupCredentials = "credentials" CommandGroupManage = "manage" CommandGroupProcess = "process" CommandGroupSubsystems = "subsystems" CommandGroupView = "view" )
Available command groups for Cobra command set-up. This influences the display of the help text for the top-level `geneos` command.
Variables ¶
var DefaultUserKeyfile = config.KeyFile(config.Path("keyfile", config.SetAppName(Execname), config.SetFileFormat("aes"), config.IgnoreWorkingDir()), )
DefaultUserKeyfile is the path to the user's key file as a config.Keyfile type
var Execname = execname // filepath.Base(os.Args[0])
Execname is the basename, without extension, of the underlying binary used to start the program. The initialising routines evaluate symlinks etc.
initialise to sensible default
var GeneosCmd = &cobra.Command{ Use: Execname + " COMMAND [flags] [TYPE] [NAME...] [parameters...]", Short: "Take control of your Geneos environments", Long: geneosCmdDescription, Example: strings.ReplaceAll(` geneos init demo -u jondoe@example.com -l geneos ps geneos restart `, "|", "`"), Annotations: map[string]string{ "needshomedir": "true", }, CompletionOptions: cobra.CompletionOptions{ DisableDefaultCmd: true, }, Version: cordial.VERSION, DisableAutoGenTag: true, DisableSuggestions: true, PersistentPreRunE: func(command *cobra.Command, args []string) (err error) { command.Root().ParseFlags(args) if quiet { zerolog.SetGlobalLevel(zerolog.Disabled) } else if debug { zerolog.SetGlobalLevel(zerolog.DebugLevel) } else { zerolog.SetGlobalLevel(zerolog.InfoLevel) } // check for "replacedby" annotation, warn the user, run the new // command later (after prerun) but if the help flag is set // output the help for the new command and cleanly exit. var newcmd *cobra.Command if r, ok := command.Annotations["replacedby"]; ok { var newargs []string newcmd, newargs, err = command.Root().Find(append(strings.Split(r, " "), args...)) if err != nil { log.Fatal().Err(err).Msg("") } if newcmd != nil { log.Warn().Msgf("Please note that the %q command has been replaced by %q\n", command.CommandPath(), newcmd.CommandPath()) command.RunE = func(cmd *cobra.Command, args []string) error { newcmd.ParseFlags(newargs) parseArgs(newcmd, newargs) return newcmd.RunE(newcmd, newcmd.Flags().Args()) } } } if r, ok := command.Annotations["aliasfor"]; ok { var newargs []string newcmd, newargs, err = command.Root().Find(append(strings.Split(r, " "), args...)) if err != nil { log.Fatal().Err(err).Msg("") } if newcmd != nil { command.RunE = func(cmd *cobra.Command, args []string) error { newcmd.ParseFlags(newargs) parseArgs(newcmd, newargs) return newcmd.RunE(newcmd, newcmd.Flags().Args()) } } } if newcmd != nil { if t, _ := command.Flags().GetBool("help"); t { command.RunE = nil command.Run = newcmd.HelpFunc() return nil } } if t, _ := command.Flags().GetBool("help"); t { command.RunE = nil command.Run = command.HelpFunc() return nil } geneosdir := geneos.Root() if geneosdir == "" { if command.Annotations["needshomedir"] == "true" { command.SetUsageTemplate(" ") return fmt.Errorf("%s", geneosUnsetError) } } if command.Name() == "help" { return nil } return parseArgs(command, args) }, }
GeneosCmd represents the base command when called without any subcommands
var Hostname string
Hostname is the cmd package global host selected ny the `--host`/`-H` option
var RunPlaceholder = func(command *cobra.Command, args []string) {}
RunPlaceholder is an empty function for commands that have to run but no do anything
Used to allow PersistentPreRun to check for aliases for legacy commands
var UserKeyFile config.KeyFile
UserKeyFile is the path to the user's key file. It starts as DefaultUserKeyFile but can be changed.
Functions ¶
func AddInstance ¶ added in v1.5.0
func AddInstance(ct *geneos.Component, addCmdExtras instance.ExtraConfigValues, items []string, args ...string) (err error)
AddInstance add an instance of ct the the option extra configuration values addCmdExtras
func CmdArgsParams ¶ added in v1.5.0
func CommandPS ¶ added in v1.5.0
CommandPS writes running instance information to STDOUT
XXX relies on global flags
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the RootCmd.
func ImportFiles ¶ added in v1.5.0
ImportFiles add a file to an instance, from local or URL overwrites without asking - use case is license files, setup files etc. backup / history track older files (date/time?) no restart or reload of components?
func RunE ¶ added in v1.5.0
RunE runs a command in a sub-package to avoid import loops. It is named to align with the cobra struct member of the same name.
The caller must have:
DisableFlagParsing: true,
set in their command struct for flags to work. Then hook this function like this in the command struct:
RunE: func(command *cobra.Command, args []string) (err error) { return RunE(command.Root(), []string{"host", "ls"}, args) },
Types ¶
This section is empty.
Source Files ¶
- add.go
- clean.go
- command.go
- copy.go
- delete.go
- disable.go
- enable.go
- groups.go
- home.go
- import.go
- legacy.go
- list.go
- login.go
- logout.go
- logs.go
- migrate.go
- move.go
- parseargs.go
- protect.go
- ps.go
- ps_linux.go
- rebuild.go
- reload.go
- restart.go
- revert.go
- root.go
- set.go
- show.go
- snapshot.go
- start.go
- stop.go
- unset.go
- version.go
Directories ¶
Path | Synopsis |
---|---|
Package aescmd groups related AES256 keyfile and crypto commands
|
Package aescmd groups related AES256 keyfile and crypto commands |
Package cfgcmd groups config commands in their own package
|
Package cfgcmd groups config commands in their own package |
Package hostcmd contains all the host subsystem commands
|
Package hostcmd contains all the host subsystem commands |
Package initcmd contains all the init subsystem commands
|
Package initcmd contains all the init subsystem commands |
Package pkgcmd contains all the package subsystem commands
|
Package pkgcmd contains all the package subsystem commands |
Package tlscmd contains all the TLS subsystem commands
|
Package tlscmd contains all the TLS subsystem commands |