Search packages, repositories and app categories

Package detailsv1.0.2

completion

A package to add shell command completion to your Dart application

AndroidiOSmacOSWindowsLinux
30-day downloads
9.4M
Likes
52
Pub points
160

Install package

flutter pub add completion

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The completion package enables shell command-line completion in Dart applications, allowing users to benefit from auto-suggestions and tab completion when interacting with CLI tools. It integrates seamlessly with the Dart command-line interface, enhancing usability for developers building interactive command-line utilities. The package supports multiple platforms including Android, iOS, macOS, Windows, and Linux, making it ideal for cross-platform CLI development. It works by registering completion handlers that respond to shell requests, improving user experience through intuitive input assistance.

Use cases

  • Building interactive CLI tools
  • Adding tab completion to command-line apps
  • Enhancing developer tool usability
  • Creating command-line interfaces with auto-suggestions
  • Supporting multi-platform CLI applications

Key features

  • Shell command completion integration
  • Cross-platform support
  • Simple API for registering completions
  • Works with Dart's command-line tools
  • Automatic handling of completion requests

Suitable for

  • Developers creating CLI applications
  • Tools requiring interactive input
  • Cross-platform command-line utilities
  • Command-line developers seeking better UX

Considerations

  • Requires shell-level configuration for full functionality
  • Limited to command-line context
  • May need platform-specific setup
  • Not suitable for GUI or web applications
  • Depends on shell environment compatibility

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package