datumforge / datum

Datum's central server
https://datum.net
Apache License 2.0
53 stars 7 forks source link

feat: generate cmd stubs #1069

Closed golanglemonade closed 1 week ago

golanglemonade commented 1 week ago

Adds two task commands that can be used to generate the stubs for cmds for the cli:

* cli:generate:                   generates a new cli cmd
* cli:generate:ro:                generates a new cli cmd with only the read cmds

If you want to generate all CRUD operations:

ask cli:generate
task: [cli:generate] go run gencmd/generate/main.go generate
Name of the command (should be the singular version of the object): MattIsTheBest
----> creating cli cmd for: MattIsTheBest
----> executing template: create.tmpl
----> executing template: delete.tmpl
----> executing template: doc.tmpl
----> executing template: get.tmpl
----> executing template: root.tmpl
----> executing template: update.tmpl

Which creates:

ls -l cmd/cli/cmd/mattisthebest/
total 48
-rw-r--r--  1 sarahfunkhouser  staff  1261 Jun 27 13:30 create.go
-rw-r--r--  1 sarahfunkhouser  staff  1086 Jun 27 13:30 delete.go
-rw-r--r--  1 sarahfunkhouser  staff   102 Jun 27 13:30 doc.go
-rw-r--r--  1 sarahfunkhouser  staff  1079 Jun 27 13:30 get.go
-rw-r--r--  1 sarahfunkhouser  staff  2570 Jun 27 13:30 root.go
-rw-r--r--  1 sarahfunkhouser  staff  1511 Jun 27 13:30 update.go

For Read-Only cmds, only the get stub is created

task cli:generate:ro            
task: [cli:generate:ro] go run gencmd/generate/main.go generate --read-only
Name of the command (should be the singular version of the object): MattIsTheBestHistory
----> creating cli cmd for: MattIsTheBestHistory
----> executing template: doc.tmpl
----> executing template: get.tmpl
----> executing template: root.tmpl

Once created, you still need to go update:

sonarcloud[bot] commented 1 week ago

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint