configMigrate() returns errors + tests (#2735)

This commit is contained in:
Anis Elleuch
2016-09-21 17:44:57 +01:00
committed by Harshavardhana
parent 018c90dae7
commit e66fb4bd7b
4 changed files with 326 additions and 60 deletions
+9 -2
View File
@@ -17,6 +17,7 @@
package cmd
import (
"errors"
"fmt"
"os"
"sort"
@@ -79,7 +80,8 @@ func init() {
func migrate() {
// Migrate config file
migrateConfig()
err := migrateConfig()
fatalIf(err, "Config migration failed.")
// Migrate other configs here.
}
@@ -157,8 +159,13 @@ func checkMainSyntax(c *cli.Context) {
func Main() {
app := registerApp()
app.Before = func(c *cli.Context) error {
configDir := c.GlobalString("config-dir")
if configDir == "" {
fatalIf(errors.New("Config directory is empty"), "Unable to get config file.")
}
// Sets new config folder.
setGlobalConfigPath(c.GlobalString("config-dir"))
setGlobalConfigPath(configDir)
// Valid input arguments to main.
checkMainSyntax(c)