-
Notifications
You must be signed in to change notification settings - Fork 913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
govc: fix host.esxcli runtime error occurred when no arguments specified #2961
Conversation
govc/host/esxcli/esxcli.go
Outdated
@@ -71,6 +72,10 @@ func (cmd *esxcli) Process(ctx context.Context) error { | |||
} | |||
|
|||
func (cmd *esxcli) Run(ctx context.Context, f *flag.FlagSet) error { | |||
if len(f.Args()) == 0 { | |||
return errors.New("no argument") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Syuparn , but could you change to flag.ErrHelp
? That's what we do in most commands as it will output the full help text for the command. I think there's a few commands using errors.New we should probably change to flag.ErrHelp. Can also use f.NArg
here:
if f.NArg() == 0 {
return flag.ErrHelp
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dougm
I changed this to print help message as you suggested.
./govc host.esxcli
Usage: ./govc host.esxcli [OPTIONS] COMMAND [ARG]...
Invoke esxcli command on HOST.
Output is rendered in table form when possible, unless disabled with '-hints=false'.
Examples:
govc host.esxcli network ip connection list
govc host.esxcli system settings advanced set -o /Net/GuestIPHack -i 1
govc host.esxcli network firewall ruleset set -r remoteSerialPort -e true
govc host.esxcli network firewall set -e false
govc host.esxcli hardware platform get
Options:
-cert= Certificate [GOVC_CERTIFICATE]
-dc= Datacenter [GOVC_DATACENTER]
-debug=false Store debug logs [GOVC_DEBUG]
-dump=false Enable Go output
-hints=true Use command info hints when formatting output
-host= Host system [GOVC_HOST]
-host.dns= Find host by FQDN
-host.ip= Find host by IP address
-host.ipath= Find host by inventory path
-host.uuid= Find host by UUID
-json=false Enable JSON output
-k=true Skip verification of server certificate [GOVC_INSECURE]
-key= Private key [GOVC_PRIVATE_KEY]
-persist-session=true Persist session to disk [GOVC_PERSIST_SESSION]
-tls-ca-certs= TLS CA certificates file [GOVC_TLS_CA_CERTS]
-tls-known-hosts= TLS known hosts file [GOVC_TLS_KNOWN_HOSTS]
-trace=false Write SOAP/REST traffic to stderr
-u=https://user@127.0.0.1:8989/sdk ESX or vCenter URL [GOVC_URL]
-verbose=false Write request/response data to stderr
-vim-namespace=vim25 Vim namespace [GOVC_VIM_NAMESPACE]
-vim-version=7.0 Vim version [GOVC_VIM_VERSION]
-xml=false Enable XML output
Closes: vmware#2960 Signed-off-by: syuparn <s.hello.spagetti@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Syuparn
Description
This PR fixes
govc host.esxcli
runtime error occurred when no arguments specified.Closes: #2960
Type of change
Please mark options that are relevant:
not work as expected)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.
Checklist:
CONTRIBUTION
guidelines of this project