diff --git a/README.md b/README.md index 8fa81a9..65dff41 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,13 @@ 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 struct +### Quick generate a struct + +```bash +gin-admin-cli gen -d ~/go/src/testapp -m SYS --structs Dictionary --structs-comment "Dictionaries management" --structs-router-prefix +``` + +### Use config file to generate struct > More examples can be found in the [examples directory](https://github.com/gin-admin/gin-admin-cli/tree/master/examples) @@ -30,8 +36,10 @@ Using `Dictionary` as an example, the configuration file is as follows `dictiona ```yaml - name: Dictionary - comment: Dictionary management for system + comment: Dictionaries management disable_pagination: true + fill_gorm_commit: true + fill_router_prefix: true tpl_type: "tree" fields: - name: Code @@ -118,20 +126,20 @@ USAGE: gin-admin-cli generate [command options] [arguments...] OPTIONS: - --dir value, -d value The project directory to generate the struct - --module value, -m value The module to generate the struct from (like: RBAC) - --module-path value The module path to generate the struct from (default: internal/mods) - --wire-path value The wire generate path to generate the struct from (default: internal/wirex) - --swag-path value The swagger generate path to generate the struct from (default: internal/swagger) - --config value, -c value The config file or directory to generate the struct from (JSON/YAML) - --structs value, -s value The struct to generate (multiple structs can be separated by a comma) - --structs-comment value Specify the struct comment - --structs-output value Specify the packages to generate the struct (default: schema,dal,biz,api) - --tpl-path value The template path to generate the struct from (default use tpls) - --tpl-type value The template type to generate the struct from (default: default) - --fe-dir value The frontend project directory to generate the UI - --fe-tpl-type value The template type to generate the frontend from (default: react) - --help, -h show help + --dir value, -d value The project directory to generate the struct + --module value, -m value The module to generate the struct from (like: RBAC) + --module-path value The module path to generate the struct from (default: internal/mods) + --wire-path value The wire generate path to generate the struct from (default: internal/wirex) + --swag-path value The swagger generate path to generate the struct from (default: internal/swagger) + --config value, -c value The config file or directory to generate the struct from (JSON/YAML) + --structs value The struct name to generate + --structs-comment value Specify the struct comment + --structs-router-prefix Use module name as router prefix (default: false) + --structs-output value Specify the packages to generate the struct (default: schema,dal,biz,api) + --tpl-path value The template path to generate the struct from (default use tpls) + --tpl-type value The template type to generate the struct from (default: default) + --fe-dir value The frontend project directory to generate the UI + --help, -h show help ``` ### Remove command diff --git a/internal/schema/struct.go b/internal/schema/struct.go index 01c0761..83c0061 100644 --- a/internal/schema/struct.go +++ b/internal/schema/struct.go @@ -28,7 +28,7 @@ type S struct { DisablePagination bool `yaml:"disable_pagination,omitempty" json:"disable_pagination,omitempty"` DisableDefaultFields bool `yaml:"disable_default_fields,omitempty" json:"disable_default_fields,omitempty"` FillGormCommit bool `yaml:"fill_gorm_commit,omitempty" json:"fill_gorm_commit,omitempty"` - FillRouterPrefix bool `yaml:"fill_router_module_name,omitempty" json:"fill_router_module_name,omitempty"` + FillRouterPrefix bool `yaml:"fill_router_prefix,omitempty" json:"fill_router_prefix,omitempty"` Fields []*Field `yaml:"fields,omitempty" json:"fields,omitempty"` GenerateFE bool `yaml:"generate_fe,omitempty" json:"generate_fe,omitempty"` FETpl string `yaml:"fe_tpl,omitempty" json:"fe_tpl,omitempty"` // react/react-v5-i18n