@@ -2,7 +2,6 @@ import 'dart:async';
22
33import 'package:args/args.dart' ;
44import 'package:args/command_runner.dart' ;
5- import 'package:cli_tools/src/better_command_runner/exit_exception.dart' ;
65
76/// A function type for executing code before running a command.
87typedef OnBeforeRunCommand = Future <void > Function (BetterCommandRunner runner);
@@ -14,11 +13,10 @@ typedef PassMessage = void Function(String message);
1413/// The [logLevel] is the log level to set.
1514/// The [commandName] is the name of the command if custom rules for log
1615/// levels are needed.
17- typedef SetLogLevel =
18- void Function ({
19- required CommandRunnerLogLevel parsedLogLevel,
20- String ? commandName,
21- });
16+ typedef SetLogLevel = void Function ({
17+ required CommandRunnerLogLevel parsedLogLevel,
18+ String ? commandName,
19+ });
2220
2321/// A function type for tracking events.
2422typedef OnAnalyticsEvent = void Function (String event);
@@ -63,19 +61,18 @@ class BetterCommandRunner extends CommandRunner {
6361 OnBeforeRunCommand ? onBeforeRunCommand,
6462 OnAnalyticsEvent ? onAnalyticsEvent,
6563 int ? wrapTextColumn,
66- }) : _logError = logError,
67- _logInfo = logInfo,
68- _onBeforeRunCommand = onBeforeRunCommand,
69- _setLogLevel = setLogLevel,
70- _onAnalyticsEvent = onAnalyticsEvent,
71- _argParser = ArgParser (usageLineLength: wrapTextColumn) {
64+ }) : _logError = logError,
65+ _logInfo = logInfo,
66+ _onBeforeRunCommand = onBeforeRunCommand,
67+ _setLogLevel = setLogLevel,
68+ _onAnalyticsEvent = onAnalyticsEvent,
69+ _argParser = ArgParser (usageLineLength: wrapTextColumn) {
7270 argParser.addFlag (
7371 BetterCommandRunnerFlags .quiet,
7472 abbr: BetterCommandRunnerFlags .quietAbbr,
7573 defaultsTo: false ,
7674 negatable: false ,
77- help:
78- 'Suppress all cli output. Is overridden by '
75+ help: 'Suppress all cli output. Is overridden by '
7976 ' -${BetterCommandRunnerFlags .verboseAbbr }, --${BetterCommandRunnerFlags .verbose }.' ,
8077 );
8178
@@ -84,8 +81,7 @@ class BetterCommandRunner extends CommandRunner {
8481 abbr: BetterCommandRunnerFlags .verboseAbbr,
8582 defaultsTo: false ,
8683 negatable: false ,
87- help:
88- 'Prints additional information useful for development. '
84+ help: 'Prints additional information useful for development. '
8985 'Overrides --${BetterCommandRunnerFlags .quietAbbr }, --${BetterCommandRunnerFlags .quiet }.' ,
9086 );
9187
@@ -120,7 +116,7 @@ class BetterCommandRunner extends CommandRunner {
120116 } on UsageException catch (e) {
121117 _onAnalyticsEvent? .call (BetterCommandRunnerAnalyticsEvents .invalid);
122118 _logError? .call (e.toString ());
123- throw ExitException (exitCodeCommandNotFound) ;
119+ rethrow ;
124120 }
125121 }
126122
@@ -176,7 +172,7 @@ class BetterCommandRunner extends CommandRunner {
176172 } on UsageException catch (e) {
177173 _logError? .call (e.toString ());
178174 _onAnalyticsEvent? .call (BetterCommandRunnerAnalyticsEvents .invalid);
179- throw ExitException (exitCodeCommandNotFound) ;
175+ rethrow ;
180176 }
181177 }
182178
0 commit comments