diff --git a/cmd/new.go b/cmd/new.go index 2b90a40..730b674 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -1,5 +1,34 @@ package cmd -func New() { +import "github.com/urfave/cli/v2" +var gitignore = `# Created by .ignore support plugin (hsz.mobi) +### Example user template template +### Example user template + +# IntelliJ project files +.idea +*.iml +out +gen +/runtime +### Go template +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with 'go test -c\' +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/` + +func New(c *cli.Context) error { + return nil } diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..c2c728a --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module golib.gaore.com/GaoreGo/beegoinit-cmd + +go 1.13 + +require ( + github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/gookit/color v1.2.8 + github.com/urfave/cli/v2 v2.2.0 +) diff --git a/main.go b/main.go index eeb8e78..89a7168 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,11 @@ package main import ( "fmt" "github.com/gookit/color" + "github.com/urfave/cli/v2" "golib.gaore.com/GaoreGo/beegoinit-cmd/cmd" + "log" + "os" + "time" ) func main() { @@ -19,5 +23,30 @@ func main() { //red := color.Red.Render //fmt.Println("how o %s", red(time.Now().Format(time.ANSIC))) fmt.Println(logo) - cmd.New() + + app := cli.App{ + Name: "beegoinit-cmd", + Usage: "Create a new project with beego init", + Commands: []*cli.Command{ + { + Name: "create", + Aliases: []string{"c"}, + Usage: "Create a new project with beego init", + Action: cmd.New, + }, + { + Name: "date", + Aliases: []string{"d"}, + Usage: "Print date", + Action: func(c *cli.Context) error { + fmt.Println(time.Now().Format(time.RFC3339)) + return nil + }, + }, + }, + } + + if err := app.Run(os.Args); err != nil { + log.Fatal(err) + } }