feat: Make it possible to customize completions for specific command and flags
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Dart
- Stars
- 54
- Forks
- 6
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from VeryGoodOpenSource/cli_completion
-
feature p3
Difficulty 3/5 1-2 days Newbie friendliness 35/100
VeryGoodOpenSource/cli_completion#90 · 1 comment · 1 reaction ·
-
feature p2
VeryGoodOpenSource/cli_completion#55 · 1 comment · 1 reaction · 1 assignee ·
-
feature p2
Difficulty 4/5 3-5 days Newbie friendliness 35/100
VeryGoodOpenSource/cli_completion#47 · 2 comments · 2 reactions ·
All issues in VeryGoodOpenSource/cli_completion
Similar issues
-
improvement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
linagora/tmail-flutter#4849 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
hiddify/hiddify-app#2348 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
mlcommons/mobile_app_open#1182 ·
-
[Bug] Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bggRGjQaUbCoE/PiliPlus#3048 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
zulip/zulip-flutter#2466 ·