Skip to content

Commit d238512

Browse files
author
Sanya Varghese
committed
fix: adding usage for no args passed
1 parent 0f9dc0c commit d238512

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

vm_metadata_export/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,16 @@ func main() {
9595
password := flag.String("password", "", "vCenter password")
9696
host := flag.String("host", "", "vCenter host")
9797

98+
flag.Usage = func() {
99+
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
100+
flag.PrintDefaults()
101+
}
102+
98103
flag.Parse()
99104

100105
if *username == "" || *password == "" || *host == "" {
101-
fmt.Println("Usage: vmmetadataexporter --username <user> --password <pass> --host <host>")
106+
fmt.Println("Error: missing required argument(s)")
107+
flag.Usage()
102108
os.Exit(1)
103109
}
104110

0 commit comments

Comments
 (0)