v0.5.1cli_completion
CommandRunner를 사용하여 구축된 Dart 명령줄 인터페이스용 완성 기능. Very Good Ventures에서 개발함.
CommandRunner를 사용하여 구축된 Dart 명령줄 인터페이스용 완성 기능. Very Good Ventures에서 제작했습니다. 🦄
^2.5.0^2.0.5^0.3.0^1.15.0^1.9.0^1.0.4^1.25.8^10.3.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Very Good Ventures Very Good Ventures
ci coverage pub package style: very good analysis License: MIT
screen
Completion functionality for Dart Command-Line Interfaces built using CommandRunner.
Developed with 💙 by Very Good Ventures 🦄
❗ In order to start using CLI Completion you must have the Dart SDK installed on your machine.
flutter pub add cli_completion
On your CommandRunner class, extend CompletionCommandRunner :
import 'package:cli_completion/cli_completion.dart';
class ExampleCommandRunner extends CompletionCommandRunner<int> {
...
This will make the first command run to install the completion files automatically. To disable that behavior, set enableAutoInstall to false:
class ExampleCommandRunner extends CompletionCommandRunner<int> {
@override
bool get enableAutoInstall => false;
...
When enableAutoInstall is set to false, users will have to call install-completion-files to install these files manually.
$ example_cli install-completion-files
Additionally, when enableAutoInstall is disabled a completion-script command is exposed. It prints the completion script for the current shell to stdout, so users can install it wherever they prefer:
$ example_cli completion-script >> ~/.zshrc
For an overview of how this package works, check out the documentation.
Handling completion requests should be straightforward.
If there are any checks (like analytics, telemetry, or anything that you may have on run or runCommand overrides) before running subcommands, make sure you fast track the completion command to skip all of the unnecessary computations.
Example:
@override
Future<int?> runCommand(ArgResults topLevelResults) async {
if (topLevelResults.command?.name == 'completion') {
super.runCommand(topLevelResults);
return;
}
// ... analytics and other unrelated stuff
If you are not using any zsh framework such as Oh My Zsh, you have to start the completion system manually.
Add the following lines to your ~/.zshrc file:
# Add this to the start of your zsh starter file (~/.zshrc)
autoload -Uz compinit
compinit