VeryGoodOpenSource / VeryGoodOpenSource/cli_completion

feat: Make it possible to customize completions for specific command and flags

Đang mở
#91 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

feature p3
Ngôn ngữ chính
Dart
Star
54
Fork
6
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
1

Mô tả

Description

I would like to have control over the completions that displayed for my command.

Let's say I have a command foo install <version>. This command also has 2 flags --dry-run and --help.

Current state

Only the flags are suggested:

$ foo install <TAB>
--help          -- Print this usage information.
--dry-run       -- Perform prechecks but do not install.
Expected state
$ foo install <TAB>
2.1.0
2.0.0
1.2.0
1.1.0
1.0.1
1.0.0

API idea:

/// Installs Flutter SDK
class InstallCommand extends CompletionCommand<int> {
  @override
  final name = 'install';

  @override
  final description = 'Installs foo version';

  /// Returns the string that will be returned when tab completion
  /// is called for this command.
  ///
  /// This method should return fast for good user experience.
  @override
  Future<String> completions() {
    print(MyFooVersionProvider.listAllVersions());
    // The above line would print:
    // 2.1.0
    // 2.0.0
    // 1.2.0
    // 1.1.0
    // 1.0.1
    // 1.0.0
  }

  @override
  Future<int> run() async { /** code **/ }

Additional Context

A similar CLI package in the Go ecosystem has this feature. See docs.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Start by reading the existing CompletionCommand behavior and how command and flag completions are currently produced; the issue names no files or tests. Done means a command such as foo install can provide its own version completions, with the behavior defined for its flags and verified against the expected tab-completion output.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart
Lĩnh vực
cli
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.