tree: a34b7093b399955f595035dfd524a50e1c83703a [path history] [tgz]
  1. bin/
  2. example/
  3. lib/
  4. .gitignore
  5. .travis.yml
  6. analysis_options.yaml
  7. BUILD.gn
  8. CHANGELOG.md
  9. LICENSE
  10. pubspec.yaml
  11. README.md
completion/README.md

Add shell command completion to your Dart console applications.

Build Status Coverage Status

To use this package, instead of this:

import 'packages:args/args.dart';

void main(List<String> args) {
  ArgParser argParser = new ArgParser();
  argParser.addFlag('option', help: 'flag help');
  // ... add more options ...
  ArgResults argResults = argParser.parse(args);
  // ...
}

do this:

import 'packages:args/args.dart';
import 'packages:completion/completion.dart' as completion;

void main(List<String> args) {
  ArgParser argParser = new ArgParser();
  argParser.addFlag('option', help: 'flag help');
  // ... add more options ...
  ArgResults argResults = completion.tryArgsCompletion(args, argParser);
  // ...
}

(The only difference is calling complete.tryArgsCompletion in place of argParser.parse)

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).

Also, see the example.