refactor CLI to reduce bloat
- Dominant language
- Go
- Stars
- 109
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
The CLI code is quite bloated with a lot of copy/paste, little sharing of code for CRUD operations, redundancy between CREATE and UPDATE, and unnecessary JSON structs for working with API responses.
Further, the use of global `Flags` across asset handlers can be confusing and should be removed. Where possible, we should remove all the global variable references that are mutable.
The intent is to refactor the code so that:
- CRUD operations share common functions more closely
- Remove the repetitive error messages which are used as format strings, and ids
- Remove all unnecessary structs which are used for working with JSON
- Exit on error, because the returned errors just bubble up to `main` which exits anyway
This should reduce significantly reduce the lines of code in the CLI - as a rough measure of bloat:
`wc -l commands/*.go` is 7204
`cat commands/*.go | sort -u | wc -l` is 3318
The CLI should be leaner and easier to work.
Contributor guide
Assessment
This issue has not been assessed yet.