mirror of https://github.com/schollz/croc.git
generic way
This commit is contained in:
parent
d518cf0c2b
commit
e1f48721a4
|
@ -1,4 +1,4 @@
|
||||||
package common
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package common
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
9
main.go
9
main.go
|
@ -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(`
|
||||||
,_
|
,_
|
||||||
|
|
Loading…
Reference in New Issue