Refactor
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/fatih/structs"
|
||||
"github.com/yudai/hcl"
|
||||
|
||||
"github.com/yudai/gotty/pkg/homedir"
|
||||
)
|
||||
|
||||
func GenerateFlags(options ...interface{}) (flags []cli.Flag, mappings map[string]string, err error) {
|
||||
@@ -100,7 +102,7 @@ func ApplyFlags(
|
||||
}
|
||||
|
||||
func ApplyConfigFile(filePath string, options ...interface{}) error {
|
||||
filePath = ExpandHomeDir(filePath)
|
||||
filePath = homedir.Expand(filePath)
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func ExpandHomeDir(path string) string {
|
||||
if path[0:2] == "~/" {
|
||||
return os.Getenv("HOME") + path[1:]
|
||||
} else {
|
||||
return path
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user