Added 'config check' to oz-setup

master
xSmurf 10 years ago
parent ca40c190df
commit 47be4813b1

@ -88,8 +88,23 @@ func main() {
} }
func handleConfigcheck(c *cli.Context) { func handleConfigcheck(c *cli.Context) {
fmt.Println("Here be dragons!") _, err := oz.LoadConfig(oz.DefaultConfigPath)
os.Exit(1) 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) { func handleConfigshow(c *cli.Context) {
@ -100,7 +115,7 @@ func handleConfigshow(c *cli.Context) {
config = oz.NewDefaultConfig() config = oz.NewDefaultConfig()
useDefaults = true useDefaults = true
} else { } 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) os.Exit(1)
} }
} }

Loading…
Cancel
Save