搜索插件、代码仓与 APP 分类

插件详情v1.0.2

completion

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

AndroidiOSmacOSWindowsLinux
近 30 天下载
941万
喜欢数
52
Pub 分数
160

安装插件

flutter pub add completion

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

完成包使 Dart 应用程序中的 shell 命令行补全成为可能,让用户在使用 CLI 工具时能够享受自动建议和 tab 补全功能。该包与 Dart 命令行界面无缝集成,提升了开发者构建交互式命令行工具的可用性。该包支持 Android、iOS、macOS、Windows 和 Linux 多个平台,非常适合跨平台 CLI 开发。它通过注册响应 shell 请求的完成处理程序来工作,通过直观的输入辅助提升用户体验。

适合场景

  • 构建交互式 CLI 工具
  • 为命令行应用程序添加标签完成
  • 提升开发者工具的可用性
  • 使用自动建议创建命令行界面
  • 支持多平台 CLI 应用程序

主要特点

  • Shell 命令补全集成
  • 跨平台支持
  • 用于注册补全的简单 API
  • 与 Dart 的命令行工具配合使用
  • 自动处理完成请求

适合对象

  • 开发 CLI 应用程序的开发者
  • 需要交互式输入的工具
  • 跨平台命令行实用工具
  • 命令行开发者寻求更好的用户体验

使用建议

  • 需要 shell 级别配置才能实现完整功能
  • 仅限命令行上下文
  • 可能需要特定平台的设置
  • 不适用于GUI或Web应用程序
  • 依赖于 shell 环境的兼容性

原始 README

以下为关联源码仓库的 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.

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目