Skip to content

Commit

Permalink
feat: add completion
Browse files Browse the repository at this point in the history
  • Loading branch information
renancaraujo committed Dec 8, 2022
1 parent 46e7eef commit 771747d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/src/command_runner.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:cli_completion/cli_completion.dart';
import 'package:mason/mason.dart' hide packageVersion;
import 'package:pub_updater/pub_updater.dart';
import 'package:usage/usage_io.dart';
Expand All @@ -18,7 +19,7 @@ const packageName = 'very_good_cli';
/// {@template very_good_command_runner}
/// A [CommandRunner] for the Very Good CLI.
/// {@endtemplate}
class VeryGoodCommandRunner extends CommandRunner<int> {
class VeryGoodCommandRunner extends CompletionCommandRunner<int> {
/// {@macro very_good_command_runner}
VeryGoodCommandRunner({
Analytics? analytics,
Expand Down Expand Up @@ -85,6 +86,7 @@ class VeryGoodCommandRunner extends CommandRunner<int> {
normalizedResponse == 'y' || normalizedResponse == 'yes';
}
final _argResults = parse(args);

if (_argResults['verbose'] == true) {
_logger.level = Level.verbose;
}
Expand All @@ -107,6 +109,11 @@ class VeryGoodCommandRunner extends CommandRunner<int> {

@override
Future<int?> runCommand(ArgResults topLevelResults) async {
if (topLevelResults.command?.name == 'completion') {
await super.runCommand(topLevelResults);
return ExitCode.success.code;
}

_logger
..detail('Argument information:')
..detail(' Top level options:');
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies:
usage: ^4.0.2
very_good_analysis: ^3.0.0
very_good_test_runner: ^0.1.2
cli_completion:
path: ../cli_completion

dev_dependencies:
build_runner: ^2.0.0
Expand Down

0 comments on commit 771747d

Please sign in to comment.