搜尋套件、儲存庫與 APP 分類

cli_completion 封面
套件詳情v0.6.0

cli_completion

為使用 CommandRunner 構建的 Dart 命令列介面提供完成功能。由 Very Good Ventures 開發。

AndroidiOSmacOSWindowsLinux
近 30 天下載
97萬
喜歡數
71
Pub 分數
150

安裝套件

flutter pub add cli_completion

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter/Dart 套件,為使用 CommandRunner 建構的命令列介面新增自動完成支援。由 Very Good Ventures 設計,此套件讓開發者能透過提供對命令、旗標與參數的智慧建議,提升 CLI 的易用性。該套件可與現有的 CommandRunner 工具無縫整合,支援 Android、iOS、macOS、Windows 及 Linux 等主要平台。它能以最少的設定,簡化互動式、使用者友善的命令列應用程式開發。

適用情境

  • 增強CLI工具的易用性
  • 為命令列應用程式添加標籤完成
  • 改進終端工作流中的開發人員體驗
  • 建構互動式 Dart 命令列工具
  • 支援複雜的參數解析並提供建議

主要特色

  • 與 CommandRunner 的無縫整合
  • 平台無關的補全支援
  • 所需設定最少
  • 即時標籤補全
  • 可擴展以支援自訂補完

適合對象

  • Dart CLI 開發人員
  • 需要互動式終端輸入的工具
  • 開源命令列項目
  • 基於 CommandRunner 的應用程式
  • 注重CLI設計中使用者體驗的團隊

使用建議

  • 需要 CommandRunner 作為依賴項
  • 僅限基於 Dart 的 CLI 工具
  • 可能需要平台特定的設定才能完全發揮功能
  • 不適用於非CLI使用案例

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

CLI Completion

Very Good Ventures Very Good Ventures

ci coverage pub package style: very good analysis License: MIT


screen

Completion functionality for Dart Command-Line Interfaces built using CommandRunner.

Developed with 💙 by Very Good Ventures 🦄

Installation 💻

❗ In order to start using CLI Completion you must have the Dart SDK installed on your machine.

flutter pub add cli_completion

Usage ✨

On your CommandRunner class, extend CompletionCommandRunner :

import 'package:cli_completion/cli_completion.dart';

class ExampleCommandRunner extends CompletionCommandRunner<int> {
...

This will make the first command run to install the completion files automatically. To disable that behavior, set enableAutoInstall to false:

class ExampleCommandRunner extends CompletionCommandRunner<int> {
  
  @override
  bool get enableAutoInstall => false;
...

When enableAutoInstall is set to false, users will have to call install-completion-files to install these files manually.

$ example_cli install-completion-files

Additionally, when enableAutoInstall is disabled a completion-script command is exposed. It prints the completion script for the current shell to stdout, so users can install it wherever they prefer:

$ example_cli completion-script >> ~/.zshrc

Documentation 📝

For an overview of how this package works, check out the documentation.


Troubleshooting 🧠🔨

Tab completion is taking too long

Handling completion requests should be straightforward.

If there are any checks (like analytics, telemetry, or anything that you may have on run or runCommand overrides) before running subcommands, make sure you fast track the completion command to skip all of the unnecessary computations.

Example:

@override
Future<int?> runCommand(ArgResults topLevelResults) async {
  if (topLevelResults.command?.name == 'completion') {
    super.runCommand(topLevelResults);
      return;
  }
  // ... analytics and other unrelated stuff 
Tab completion is not working on my zsh terminal

If you are not using any zsh framework such as Oh My Zsh, you have to start the completion system manually.

Add the following lines to your ~/.zshrc file:

# Add this to the start of your zsh starter file (~/.zshrc)
autoload -Uz compinit
compinit

所屬分類

依賴

依賴清單 5 項

原始碼儲存庫

使用此套件的專案