Skip to content

Commit

Permalink
fix: Fix new command and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
LyricTian committed Nov 2, 2023
1 parent 45cd65c commit ee54662
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: build

RELEASE_VERSION = v10.0.0-beta
RELEASE_VERSION = v10.0.0

APP = gin-admin-cli
BIN = ${APP}
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# [gin-admin](https://github.com/LyricTian/gin-admin) efficiency assistant
# [GIN-Admin](https://github.com/LyricTian/gin-admin) efficiency assistant

> A gin-admin efficiency assistant that provides project initialization, code generation, greatly improves work efficiency, and quickly completes the development of business logic.
## Dependencies

- [Go](https://golang.org/) 1.19+
- [Wire](github.com/google/wire) `go install github.com/google/wire/cmd/wire@latest`
- [Swag](github.com/swaggo/swag) `go install github.com/swaggo/swag/cmd/swag@latest`

## Quick start

### Get and install
Expand All @@ -16,7 +22,9 @@ go install github.com/gin-admin/gin-admin-cli/v10@latest
gin-admin-cli new -d ~/go/src --name testapp --desc 'A test API service based on golang.' --pkg 'github.com/xxx/testapp'
```

### Generate a new module
### Generate a new struct

> More examples can be found in the [examples directory](https://github.com/gin-admin/gin-admin-cli/tree/master/examples)
Using `Dictionary` as an example, the configuration file is as follows `dictionary.yaml`:

Expand Down Expand Up @@ -75,6 +83,8 @@ gin-admin-cli rm -d ~/go/src/testapp -m SYS -s Dictionary

## Command help

### New command

```text
NAME:
gin-admin-cli new - Create a new project
Expand All @@ -93,6 +103,8 @@ OPTIONS:
--help, -h show help
```

### Generate command

```text
NAME:
gin-admin-cli generate - Generate structs to the specified module, support config file
Expand All @@ -115,6 +127,8 @@ OPTIONS:
--help, -h show help
```

### Remove command

```text
NAME:
gin-admin-cli remove - Remove structs from the module
Expand Down
2 changes: 1 addition & 1 deletion internal/actions/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (a *NewAction) Run(ctx context.Context) error {

fmt.Println("🎉 Congratulations, your project has been created successfully.")
fmt.Println("------------------------------------------------------------")
_ = utils.ExecTree(projectDir)
fmt.Println(utils.GetDefaultProjectTree())
fmt.Println("------------------------------------------------------------")

fmt.Println("🚀 You can execute the following commands to start the project:")
Expand Down
63 changes: 62 additions & 1 deletion internal/utils/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,70 @@ func ExecTree(dir string) error {
return nil
}

cmd := exec.Command(localPath, "-L", "4", "-I", ".git", "-I", "pkg")
cmd := exec.Command(localPath, "-L", "4", "-I", ".git", "-I", "pkg", "--dirsfirst")
cmd.Dir = dir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stdout
return cmd.Run()
}

func GetDefaultProjectTree() string {
return `
├── cmd
│   ├── start.go
│   ├── stop.go
│   └── version.go
├── configs
│   ├── dev
│   │   ├── logging.toml
│   │   ├── middleware.toml
│   │   └── server.toml
│   ├── menu.json
│   └── rbac_model.conf
├── internal
│   ├── bootstrap
│   │   ├── bootstrap.go
│   │   ├── http.go
│   │   └── logger.go
│   ├── config
│   │   ├── config.go
│   │   ├── consts.go
│   │   ├── middleware.go
│   │   └── parse.go
│   ├── mods
│   │   ├── rbac
│   │   │   ├── api
│   │   │   ├── biz
│   │   │   ├── dal
│   │   │   ├── schema
│   │   │   ├── casbin.go
│   │   │   ├── main.go
│   │   │   └── wire.go
│   │   ├── sys
│   │   │   ├── api
│   │   │   ├── biz
│   │   │   ├── dal
│   │   │   ├── schema
│   │   │   ├── main.go
│   │   │   └── wire.go
│   │   └── mods.go
│   ├── utility
│   │   └── prom
│   │   └── prom.go
│   └── wirex
│   ├── injector.go
│   ├── wire.go
│   └── wire_gen.go
├── test
│   ├── menu_test.go
│   ├── role_test.go
│   ├── test.go
│   └── user_test.go
├── Dockerfile
├── Makefile
├── README.md
├── go.mod
├── go.sum
└── main.go
`
}
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ var f embed.FS
var VERSION = "v10.0.0"

func main() {
defer zap.S().Sync()
defer func() {
_ = zap.S().Sync()
}()

// Set the embed.FS to the fs package
tfs.SetEFS(f)
Expand Down

0 comments on commit ee54662

Please sign in to comment.