generic way

This commit is contained in:
smileboywtu 2018-02-09 23:28:01 +08:00 committed by Zack Scholl
parent d518cf0c2b
commit e1f48721a4
3 changed files with 6 additions and 7 deletions

View File

@ -1,4 +1,4 @@
package common package main
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package common package main
import ( import (
"io/ioutil" "io/ioutil"

View File

@ -7,7 +7,6 @@ import (
"strings" "strings"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/yudai/gotty/pkg/homedir" "github.com/yudai/gotty/pkg/homedir"
"github.com/smileboywtu/croc/common"
) )
const BUFFERSIZE = 1024 const BUFFERSIZE = 1024
@ -44,11 +43,11 @@ func main() {
cli.AppHelpTemplate = helpTemplate cli.AppHelpTemplate = helpTemplate
appOptions := &AppConfig{} appOptions := &AppConfig{}
if err := common.ApplyDefaultValues(appOptions); err != nil { if err := ApplyDefaultValues(appOptions); err != nil {
exit(err, 1) exit(err, 1)
} }
cliFlags, flagMappings, err := common.GenerateFlags(appOptions) cliFlags, flagMappings, err := GenerateFlags(appOptions)
if err != nil { if err != nil {
exit(err, 3) exit(err, 3)
} }
@ -68,12 +67,12 @@ func main() {
configFile := c.String("config") configFile := c.String("config")
_, err := os.Stat(homedir.Expand(configFile)) _, err := os.Stat(homedir.Expand(configFile))
if configFile != "~/.croc" || !os.IsNotExist(err) { if configFile != "~/.croc" || !os.IsNotExist(err) {
if err := common.ApplyConfigFileYaml(configFile, appOptions); err != nil { if err := ApplyConfigFileYaml(configFile, appOptions); err != nil {
exit(err, 2) exit(err, 2)
} }
} }
common.ApplyFlags(cliFlags, flagMappings, c, appOptions) ApplyFlags(cliFlags, flagMappings, c, appOptions)
if !appOptions.HideLogo { if !appOptions.HideLogo {
fmt.Println(` fmt.Println(`
,_ ,_