Skip to content

Commit ee54662

Browse files
committed
fix: Fix new command and update readme
1 parent 45cd65c commit ee54662

File tree

5 files changed

+83
-6
lines changed

5 files changed

+83
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build
22

3-
RELEASE_VERSION = v10.0.0-beta
3+
RELEASE_VERSION = v10.0.0
44

55
APP = gin-admin-cli
66
BIN = ${APP}

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# [gin-admin](https://github.com/LyricTian/gin-admin) efficiency assistant
1+
# [GIN-Admin](https://github.com/LyricTian/gin-admin) efficiency assistant
22

33
> A gin-admin efficiency assistant that provides project initialization, code generation, greatly improves work efficiency, and quickly completes the development of business logic.
44
5+
## Dependencies
6+
7+
- [Go](https://golang.org/) 1.19+
8+
- [Wire](github.com/google/wire) `go install github.com/google/wire/cmd/wire@latest`
9+
- [Swag](github.com/swaggo/swag) `go install github.com/swaggo/swag/cmd/swag@latest`
10+
511
## Quick start
612

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

19-
### Generate a new module
25+
### Generate a new struct
26+
27+
> More examples can be found in the [examples directory](https://github.com/gin-admin/gin-admin-cli/tree/master/examples)
2028
2129
Using `Dictionary` as an example, the configuration file is as follows `dictionary.yaml`:
2230

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

7684
## Command help
7785

86+
### New command
87+
7888
```text
7989
NAME:
8090
gin-admin-cli new - Create a new project
@@ -93,6 +103,8 @@ OPTIONS:
93103
--help, -h show help
94104
```
95105

106+
### Generate command
107+
96108
```text
97109
NAME:
98110
gin-admin-cli generate - Generate structs to the specified module, support config file
@@ -115,6 +127,8 @@ OPTIONS:
115127
--help, -h show help
116128
```
117129

130+
### Remove command
131+
118132
```text
119133
NAME:
120134
gin-admin-cli remove - Remove structs from the module

internal/actions/new.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (a *NewAction) Run(ctx context.Context) error {
140140

141141
fmt.Println("🎉 Congratulations, your project has been created successfully.")
142142
fmt.Println("------------------------------------------------------------")
143-
_ = utils.ExecTree(projectDir)
143+
fmt.Println(utils.GetDefaultProjectTree())
144144
fmt.Println("------------------------------------------------------------")
145145

146146
fmt.Println("🚀 You can execute the following commands to start the project:")

internal/utils/command.go

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,70 @@ func ExecTree(dir string) error {
155155
return nil
156156
}
157157

158-
cmd := exec.Command(localPath, "-L", "4", "-I", ".git", "-I", "pkg")
158+
cmd := exec.Command(localPath, "-L", "4", "-I", ".git", "-I", "pkg", "--dirsfirst")
159159
cmd.Dir = dir
160160
cmd.Stdout = os.Stdout
161161
cmd.Stderr = os.Stdout
162162
return cmd.Run()
163163
}
164+
165+
func GetDefaultProjectTree() string {
166+
return `
167+
├── cmd
168+
│   ├── start.go
169+
│   ├── stop.go
170+
│   └── version.go
171+
├── configs
172+
│   ├── dev
173+
│   │   ├── logging.toml
174+
│   │   ├── middleware.toml
175+
│   │   └── server.toml
176+
│   ├── menu.json
177+
│   └── rbac_model.conf
178+
├── internal
179+
│   ├── bootstrap
180+
│   │   ├── bootstrap.go
181+
│   │   ├── http.go
182+
│   │   └── logger.go
183+
│   ├── config
184+
│   │   ├── config.go
185+
│   │   ├── consts.go
186+
│   │   ├── middleware.go
187+
│   │   └── parse.go
188+
│   ├── mods
189+
│   │   ├── rbac
190+
│   │   │   ├── api
191+
│   │   │   ├── biz
192+
│   │   │   ├── dal
193+
│   │   │   ├── schema
194+
│   │   │   ├── casbin.go
195+
│   │   │   ├── main.go
196+
│   │   │   └── wire.go
197+
│   │   ├── sys
198+
│   │   │   ├── api
199+
│   │   │   ├── biz
200+
│   │   │   ├── dal
201+
│   │   │   ├── schema
202+
│   │   │   ├── main.go
203+
│   │   │   └── wire.go
204+
│   │   └── mods.go
205+
│   ├── utility
206+
│   │   └── prom
207+
│   │   └── prom.go
208+
│   └── wirex
209+
│   ├── injector.go
210+
│   ├── wire.go
211+
│   └── wire_gen.go
212+
├── test
213+
│   ├── menu_test.go
214+
│   ├── role_test.go
215+
│   ├── test.go
216+
│   └── user_test.go
217+
├── Dockerfile
218+
├── Makefile
219+
├── README.md
220+
├── go.mod
221+
├── go.sum
222+
└── main.go
223+
`
224+
}

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ var f embed.FS
1616
var VERSION = "v10.0.0"
1717

1818
func main() {
19-
defer zap.S().Sync()
19+
defer func() {
20+
_ = zap.S().Sync()
21+
}()
2022

2123
// Set the embed.FS to the fs package
2224
tfs.SetEFS(f)

0 commit comments

Comments
 (0)