apache / apache/openwhisk-cli

refactor CLI to reduce bloat

Aperta
#314 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
help wanted
Lingua principale
Go
Stelle
109
Fork
98
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia esaminando commands/*.go e il flusso degli errori fino a main, quindi confronta gli handler CRUD ripetuti e le relative strutture di risposta API. Fai un inventario dei Flags globali mutabili e delle operazioni duplicate prima di scegliere un confine di refactoring mirato. Il lavoro è completato quando la CLI presenta meno duplicazione e meno codice superfluo, preserva il comportamento CRUD esistente e termina correttamente in caso di errori.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go
Ambito
cli
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.