completion
Dart 애플리케이션에 쉘 명령 완성 기능을 추가하는 패키지
응용 프로그램에 쉘 명령 완성 기능을 추가하기 위한 패키지
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Add shell command completion to your Dart console applications.
Dart CI pub package package publisher
To use this package, instead of this:
import 'package:args/args.dart';
void main(List<String> args) {
final argParser = ArgParser()..addFlag('option', help: 'flag help');
// ... add more options ...
final argResults = argParser.parse(args);
// ...
}
do this:
import 'package:args/args.dart';
import 'package:completion/completion.dart' as completion;
void main(List<String> args) {
final argParser = ArgParser()..addFlag('option', help: 'flag help');
// ... add more options ...
final argResults = completion.tryArgsCompletion(args, argParser);
if (argResults == null) return;
// ...
}
(The main difference is calling completion.tryArgsCompletion in place of
argParser.parse and returning early when it returns null.)
This will add a "completion" command to your app, which the shell will use to complete arguments.
To generate the setup script automatically, call generateCompletionScript with
the names of the executables that your Dart script runs as (typically just one,
but it could be more), along with the target Shell.
Also, see the example.