Skip to content

Commit

Permalink
actually, do "check which commands should not do anything without nam…
Browse files Browse the repository at this point in the history
…es (e.g. set) and output usage #134" better
  • Loading branch information
pgalbavy-itrs committed Jun 22, 2023
1 parent b8159e8 commit 65a058a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
6 changes: 4 additions & 2 deletions tools/geneos/cmd/cfgcmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ geneos config set config.rebuild=always
"wildcard": "false",
"needshomedir": "false",
},
RunE: func(command *cobra.Command, _ []string) (err error) {
RunE: func(command *cobra.Command, origargs []string) (err error) {
_, _, params := cmd.CmdArgsParams(command)

if len(origargs) == 0 && command.Flags().NFlag() == 0 {
return command.Usage()
}
cf, _ := config.Load(cmd.Execname,
config.IgnoreSystemDir(),
config.IgnoreWorkingDir(),
Expand Down
5 changes: 4 additions & 1 deletion tools/geneos/cmd/cfgcmd/unset.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ var configUnsetCmd = &cobra.Command{
"wildcard": "false",
"needshomedir": "false",
},
RunE: func(command *cobra.Command, _ []string) error {
RunE: func(command *cobra.Command, origargs []string) error {
var changed bool
if len(origargs) == 0 && command.Flags().NFlag() == 0 {
return command.Usage()
}

_, args := cmd.CmdArgs(command)
orig, _ := config.Load(cmd.Execname, config.IgnoreWorkingDir(), config.IgnoreSystemDir())
Expand Down
5 changes: 4 additions & 1 deletion tools/geneos/cmd/hostcmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ var hostSetCmd = &cobra.Command{
"wildcard": "false",
"needshomedir": "false",
},
RunE: func(command *cobra.Command, _ []string) (err error) {
RunE: func(command *cobra.Command, origargs []string) (err error) {
if len(origargs) == 0 && command.Flags().NFlag() == 0 {
return command.Usage()
}
_, args, params := cmd.CmdArgsParams(command)
var password string
var hosts []*geneos.Host
Expand Down
2 changes: 1 addition & 1 deletion tools/geneos/cmd/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ geneos set ...
"needshomedir": "true",
},
RunE: func(cmd *cobra.Command, origargs []string) error {
if len(origargs) == 0 {
if len(origargs) == 0 && cmd.Flags().NFlag() == 0 {
return cmd.Usage()
}
ct, args, params := CmdArgsParams(cmd)
Expand Down
5 changes: 4 additions & 1 deletion tools/geneos/cmd/unset.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ geneos unset san -g Gateway1
"wildcard": "true",
"needshomedir": "true",
},
RunE: func(cmd *cobra.Command, _ []string) error {
RunE: func(cmd *cobra.Command, origargs []string) error {
if len(origargs) == 0 && cmd.Flags().NFlag() == 0 {
return cmd.Usage()
}
ct, args := CmdArgs(cmd)
return instance.ForAll(ct, Hostname, unsetInstance, args, []string{})
},
Expand Down

0 comments on commit 65a058a

Please sign in to comment.