liangzy 3 роки тому
джерело
коміт
77010a08b7
3 змінених файлів з 69 додано та 2 видалено
  1. +30
    -1
      cmd/new.go
  2. +9
    -0
      go.mod
  3. +30
    -1
      main.go

+ 30
- 1
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
}

+ 9
- 0
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
)

+ 30
- 1
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)
}
}

Завантаження…
Відмінити
Зберегти