From 47be4813b143511689e42f93dfc5b4ebceff70df Mon Sep 17 00:00:00 2001 From: xSmurf Date: Tue, 16 Jun 2015 01:06:33 +0000 Subject: [PATCH] Added 'config check' to oz-setup --- cmd/oz-setup/main.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/oz-setup/main.go b/cmd/oz-setup/main.go index 46df88e..8c909d4 100644 --- a/cmd/oz-setup/main.go +++ b/cmd/oz-setup/main.go @@ -88,8 +88,23 @@ func main() { } func handleConfigcheck(c *cli.Context) { - fmt.Println("Here be dragons!") - os.Exit(1) + _, err := oz.LoadConfig(oz.DefaultConfigPath) + if err != nil { + if !os.IsNotExist(err) { + fmt.Fprintf(os.Stderr, "Could not load configuration `%s`: %v\n", oz.DefaultConfigPath, err) + os.Exit(1) + } + } + + OzConfig = loadConfig() + _, err = oz.LoadProfiles(OzConfig.ProfileDir) + if err != nil { + fmt.Fprintf(os.Stderr, "Unable to load profiles from `%s`: %v\n", OzConfig.ProfileDir, err) + os.Exit(1) + } + + fmt.Println("Configurations and profiles ok!") + os.Exit(0) } func handleConfigshow(c *cli.Context) { @@ -100,7 +115,7 @@ func handleConfigshow(c *cli.Context) { config = oz.NewDefaultConfig() useDefaults = true } else { - fmt.Fprintf(os.Stderr, "Could not load configuration: %s", oz.DefaultConfigPath, err) + fmt.Fprintf(os.Stderr, "Could not load configuration `%s`: %v\n", oz.DefaultConfigPath, err) os.Exit(1) } }