VeryGoodOpenSource / VeryGoodOpenSource/cli_completion
feat: Make it possible to customize completions for specific command and flags
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Dart
- Sterne
- 54
- Forks
- 6
- Ø Merge
- 6 T. 17 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- dart
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100