project init

This commit is contained in:
liangzy 2020-08-31 11:56:54 +08:00
parent f828e3090d
commit 77010a08b7
3 changed files with 69 additions and 2 deletions

View File

@ -1,5 +1,34 @@
package cmd 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
} }

9
go.mod Normal file
View File

@ -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
)

31
main.go
View File

@ -3,7 +3,11 @@ package main
import ( import (
"fmt" "fmt"
"github.com/gookit/color" "github.com/gookit/color"
"github.com/urfave/cli/v2"
"golib.gaore.com/GaoreGo/beegoinit-cmd/cmd" "golib.gaore.com/GaoreGo/beegoinit-cmd/cmd"
"log"
"os"
"time"
) )
func main() { func main() {
@ -19,5 +23,30 @@ func main() {
//red := color.Red.Render //red := color.Red.Render
//fmt.Println("how o %s", red(time.Now().Format(time.ANSIC))) //fmt.Println("how o %s", red(time.Now().Format(time.ANSIC)))
fmt.Println(logo) 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)
}
} }