Giter Club home page Giter Club logo

gin-admin-cli's Introduction

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 1.19+
  • Wire go install github.com/google/wire/cmd/wire@latest
  • Swag go install github.com/swaggo/swag/cmd/swag@latest

Quick start

Get and install

go install github.com/gin-admin/gin-admin-cli/v10@latest

Create a new project

gin-admin-cli new -d ~/go/src --name testapp --desc 'A test API service based on golang.' --pkg 'github.com/xxx/testapp'

Quick generate a struct

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

Using Dictionary as an example, the configuration file is as follows dictionary.yaml:

- name: Dictionary
  comment: Dictionaries management
  disable_pagination: true
  fill_gorm_commit: true
  fill_router_prefix: true
  tpl_type: "tree"
  fields:
    - name: Code
      type: string
      comment: Code of dictionary (unique for same parent)
      gorm_tag: "size:32;"
      form:
        binding_tag: "required,max=32"
    - name: Name
      type: string
      comment: Display name of dictionary
      gorm_tag: "size:128;index"
      query:
        name: LikeName
        in_query: true
        form_tag: name
        op: LIKE
      form:
        binding_tag: "required,max=128"
    - name: Description
      type: string
      comment: Details about dictionary
      gorm_tag: "size:1024"
      form: {}
    - name: Sequence
      type: int
      comment: Sequence for sorting
      gorm_tag: "index;"
      order: DESC
      form: {}
    - name: Status
      type: string
      comment: Status of dictionary (disabled, enabled)
      gorm_tag: "size:20;index"
      query: {}
      form:
        binding_tag: "required,oneof=disabled enabled"
./gin-admin-cli gen -d ~/go/src/testapp -m SYS -c dictionary.yaml

Remove a struct from the module

gin-admin-cli rm -d ~/go/src/testapp -m SYS -s Dictionary

Command help

New command

NAME:
   gin-admin-cli new - Create a new project

USAGE:
   gin-admin-cli new [command options] [arguments...]

OPTIONS:
   --dir value, -d value  The directory to generate the project (default: current directory)
   --name value           The project name
   --app-name value       The application name (default: project name)
   --desc value           The project description
   --version value        The project version (default: 1.0.0)
   --pkg value            The project package name (default: project name)
   --git-url value        Use git repository to initialize the project (default: https://github.com/LyricTian/gin-admin.git)
   --git-branch value     Use git branch to initialize the project (default: main)
   --fe-dir value         The frontend directory to generate the project (if empty, the frontend project will not be generated)
   --fe-name value        The frontend project name (default: frontend)
   --fe-git-url value     Use git repository to initialize the frontend project (default: https://github.com/gin-admin/gin-admin-frontend.git)
   --fe-git-branch value  Use git branch to initialize the frontend project (default: main)
   --help, -h             show help

Generate command

NAME:
   gin-admin-cli generate - Generate structs to the specified module, support config file

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

NAME:
   gin-admin-cli remove - Remove structs from the module

USAGE:
   gin-admin-cli remove [command options] [arguments...]

OPTIONS:
   --dir value, -d value      The directory to remove the struct from
   --module value, -m value   The module to remove the struct from
   --module-path value        The module path to remove the struct from (default: internal/mods)
   --structs value, -s value  The struct to remove (multiple structs can be separated by a comma)
   --config value, -c value   The config file to generate the struct from (JSON/YAML)
   --wire-path value          The wire generate path to remove the struct from (default: internal/library/wirex)
   --swag-path value          The swagger generate path to remove the struct from (default: internal/swagger)
   --help, -h                 show help

MIT License

Copyright (c) 2023 Lyric

gin-admin-cli's People

Contributors

lyrictian avatar sigam-zq avatar whtiehack avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.