diff --git a/ciao-cli/main.go b/ciao-cli/main.go index 4d8eb9fa5..6c37ea975 100644 --- a/ciao-cli/main.go +++ b/ciao-cli/main.go @@ -51,6 +51,7 @@ func (c *command) run(args []string) error { c.usage(cmdName) } args = subCmd.parseArgs(args[2:]) + prepareForCommand() return subCmd.run(args) } @@ -341,21 +342,8 @@ func checkCompulsoryOptions() { } } -func main() { +func prepareForCommand() { var err error - - flag.Usage = usage - flag.Parse() - - getCiaoEnvVariables() - checkCompulsoryOptions() - - // Print usage if no arguments are given - args := flag.Args() - if len(args) < 1 { - usage() - } - /* Load CA file if necessary */ if *caCertFile != "" { caCert, err := ioutil.ReadFile(*caCertFile) @@ -382,6 +370,22 @@ func main() { if err != nil { fatalf(err.Error()) } +} + +func main() { + var err error + + flag.Usage = usage + flag.Parse() + + getCiaoEnvVariables() + checkCompulsoryOptions() + + // Print usage if no arguments are given + args := flag.Args() + if len(args) < 1 { + usage() + } // Find command in cmdline args cmdName := args[0]