FLUTTER ECOSYSTEM

kevmoo/completion.dart

一个用于向您的应用程序添加 shell 命令补全功能的包

completion.dart 项目封面
Stars
62
Forks
11
最近推送(UTC)
2026年9月12日
项目状态
未归档
Kevin Moore GitHub avatar
GITHUB User

Kevin Moore ↗

A Product Manager at @google working on @dart-lang and @flutter web technologies

@dart-lang @flutter @googleSeattle, WA, USA官方网站 ↗
语言DartShell

此仓库发布的插件

使用的依赖

依赖清单 8 项

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

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.