From e1f48721a49a0695b4cc603e6f66cfcf6fe4f5c4 Mon Sep 17 00:00:00 2001 From: smileboywtu Date: Fri, 9 Feb 2018 23:28:01 +0800 Subject: [PATCH] generic way --- common/default.go => default.go | 2 +- common/flags.go => flags.go | 2 +- main.go | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) rename common/default.go => default.go (98%) rename common/flags.go => flags.go (99%) diff --git a/common/default.go b/default.go similarity index 98% rename from common/default.go rename to default.go index 30a9bdb7..b0459298 100644 --- a/common/default.go +++ b/default.go @@ -1,4 +1,4 @@ -package common +package main import ( "fmt" diff --git a/common/flags.go b/flags.go similarity index 99% rename from common/flags.go rename to flags.go index a3d0ac19..9d65c65d 100644 --- a/common/flags.go +++ b/flags.go @@ -1,4 +1,4 @@ -package common +package main import ( "io/ioutil" diff --git a/main.go b/main.go index d2ade975..2b59c3dc 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/urfave/cli" "github.com/yudai/gotty/pkg/homedir" - "github.com/smileboywtu/croc/common" ) const BUFFERSIZE = 1024 @@ -44,11 +43,11 @@ func main() { cli.AppHelpTemplate = helpTemplate appOptions := &AppConfig{} - if err := common.ApplyDefaultValues(appOptions); err != nil { + if err := ApplyDefaultValues(appOptions); err != nil { exit(err, 1) } - cliFlags, flagMappings, err := common.GenerateFlags(appOptions) + cliFlags, flagMappings, err := GenerateFlags(appOptions) if err != nil { exit(err, 3) } @@ -68,12 +67,12 @@ func main() { configFile := c.String("config") _, err := os.Stat(homedir.Expand(configFile)) if configFile != "~/.croc" || !os.IsNotExist(err) { - if err := common.ApplyConfigFileYaml(configFile, appOptions); err != nil { + if err := ApplyConfigFileYaml(configFile, appOptions); err != nil { exit(err, 2) } } - common.ApplyFlags(cliFlags, flagMappings, c, appOptions) + ApplyFlags(cliFlags, flagMappings, c, appOptions) if !appOptions.HideLogo { fmt.Println(` ,_