|
1 | | -# Cli Completion |
2 | 1 |
|
| 2 | +# CLI Completion |
| 3 | + |
| 4 | +[![Very Good Ventures][logo_white]][very_good_ventures_link_dark] |
| 5 | +[![Very Good Ventures][logo_black]][very_good_ventures_link_light] |
| 6 | + |
| 7 | +[![pub package][pub_badge]][pub_link] |
3 | 8 | [![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] |
4 | | -[](https://github.com/felangel/mason) |
5 | 9 | [![License: MIT][license_badge]][license_link] |
6 | 10 |
|
7 | | -Completion toolkit for Command runner based Dart CLIs |
| 11 | +--- |
8 | 12 |
|
9 | | -## Installation 💻 |
| 13 | +Completion functionality for Dart Command-Line Interfaces built using CommandRunner. |
10 | 14 |
|
11 | | -**❗ In order to start using Cli Completion you must have the [Dart SDK][dart_install_link] installed on your machine.** |
| 15 | +Developed with 💙 by [Very Good Ventures][very_good_ventures_link] 🦄 |
12 | 16 |
|
13 | | -Add `cli_completion` to your `pubspec.yaml`: |
14 | 17 |
|
15 | | -```yaml |
16 | | -dependencies: |
17 | | - cli_completion: |
18 | | -``` |
| 18 | +## Installation 💻 |
19 | 19 |
|
20 | | -Install it: |
| 20 | +**❗ In order to start using CLI Completion you must have the [Dart SDK][dart_install_link] installed |
| 21 | +on your machine.** |
21 | 22 |
|
22 | | -```sh |
23 | | -dart pub get |
| 23 | +``` |
| 24 | +flutter pub add cli_completion |
24 | 25 | ``` |
25 | 26 |
|
26 | | ---- |
27 | 27 |
|
28 | | -## Continuous Integration 🤖 |
29 | 28 |
|
30 | | -Cli Completion comes with a built-in [GitHub Actions workflow][github_actions_link] powered by [Very Good Workflows][very_good_workflows_link] but you can also add your preferred CI/CD solution. |
| 29 | +## Usage ✨ |
31 | 30 |
|
32 | | -Out of the box, on each pull request and push, the CI `formats`, `lints`, and `tests` the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses [Very Good Analysis][very_good_analysis_link] for a strict set of analysis options used by our team. Code coverage is enforced using the [Very Good Workflows][very_good_coverage_link]. |
| 31 | +On your `CommandRunner` class, extend `CompletionCommandRunner` : |
33 | 32 |
|
34 | | ---- |
| 33 | +```dart |
| 34 | +import 'package:cli_completion/cli_completion.dart'; |
35 | 35 |
|
36 | | -## Running Tests 🧪 |
| 36 | +class ExampleCommandRunner extends CompletionCommandRunner<int> { |
| 37 | +... |
| 38 | +``` |
| 39 | +This will make the first command run to install the completion files automatically. To disable that behavior, set `enableAutoInstall` to false: |
| 40 | + |
| 41 | +```dart |
| 42 | +class ExampleCommandRunner extends **CompletionCommandRunner**<int> { |
| 43 | + |
| 44 | + @override |
| 45 | + bool get enableAutoInstall => false; |
| 46 | +... |
| 47 | +``` |
37 | 48 |
|
38 | | -To run all unit tests: |
| 49 | +When `enableAutoInstall` is set to false, users will have to call `install-completion-files` to install these files manually. |
39 | 50 |
|
40 | | -```sh |
41 | | -dart pub global activate coverage 1.2.0 |
42 | | -dart test --coverage=coverage |
43 | | -dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info |
| 51 | +```bash |
| 52 | +$ example_cli install-completion-files |
44 | 53 | ``` |
45 | 54 |
|
46 | | -To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov). |
| 55 | +## Documentation 📝 |
| 56 | + |
| 57 | +For an overview of how this package works, check out the [documentation][docs_link]. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### ⚠️ Using analytics |
| 62 | + |
| 63 | +Handling completion requests should be straightforward. |
| 64 | + |
| 65 | +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. |
47 | 66 |
|
48 | | -```sh |
49 | | -# Generate Coverage Report |
50 | | -genhtml coverage/lcov.info -o coverage/ |
| 67 | +Example: |
51 | 68 |
|
52 | | -# Open Coverage Report |
53 | | -open coverage/index.html |
| 69 | +```dart |
| 70 | +@override |
| 71 | +Future<int?> runCommand(ArgResults topLevelResults) async { |
| 72 | + if (topLevelResults.command?.name == 'completion') { |
| 73 | + super.runCommand(topLevelResults); |
| 74 | + return; |
| 75 | + } |
| 76 | + // ... analytics and other unrelated stuff |
54 | 77 | ``` |
55 | 78 |
|
56 | 79 | [dart_install_link]: https://dart.dev/get-dart |
57 | | -[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions |
58 | 80 | [license_badge]: https://img.shields.io/badge/license-MIT-blue.svg |
59 | 81 | [license_link]: https://opensource.org/licenses/MIT |
60 | 82 | [logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only |
61 | 83 | [logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only |
62 | | -[mason_link]: https://github.com/felangel/mason |
63 | 84 | [very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg |
64 | 85 | [very_good_analysis_link]: https://pub.dev/packages/very_good_analysis |
65 | | -[very_good_coverage_link]: https://github.com/marketplace/actions/very-good-coverage |
66 | 86 | [very_good_ventures_link]: https://verygood.ventures |
67 | 87 | [very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only |
68 | 88 | [very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only |
69 | 89 | [very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows |
| 90 | +[docs_link]: https://github.com/VeryGoodOpenSource/cli_completion/tree/main/doc |
| 91 | +[pub_link]: https://cli_completion.pckg.pub |
| 92 | +[pub_badge]: https://img.shields.io/pub/v/cli_completion.svg |
0 commit comments