VeryGoodOpenSource / VeryGoodOpenSource/cli_completion
feat: Make it possible to customize completions for specific command and flags
Nessuno ha ancora preso questa issue.
- Lingua principale
- Dart
- Stelle
- 54
- Fork
- 6
- Merge medio
- 6g 17h
- PR unite (30g)
- 1
Descrizione
Description
I would like to have control over the completions that displayed for my command.
Let's say I have a command foo install <version>. This command also has 2 flags --dry-run and --help.
Current state
Only the flags are suggested:
$ foo install <TAB>
--help -- Print this usage information.
--dry-run -- Perform prechecks but do not install.
Expected state
$ foo install <TAB>
2.1.0
2.0.0
1.2.0
1.1.0
1.0.1
1.0.0
API idea:
/// Installs Flutter SDK
class InstallCommand extends CompletionCommand<int> {
@override
final name = 'install';
@override
final description = 'Installs foo version';
/// Returns the string that will be returned when tab completion
/// is called for this command.
///
/// This method should return fast for good user experience.
@override
Future<String> completions() {
print(MyFooVersionProvider.listAllVersions());
// The above line would print:
// 2.1.0
// 2.0.0
// 1.2.0
// 1.1.0
// 1.0.1
// 1.0.0
}
@override
Future<int> run() async { /** code **/ }
Additional Context
A similar CLI package in the Go ecosystem has this feature. See docs.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Start by reading the existing CompletionCommand behavior and how command and flag completions are currently produced; the issue names no files or tests. Done means a command such as foo install can provide its own version completions, with the behavior defined for its flags and verified against the expected tab-completion output.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- dart
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 30/100