File tree Expand file tree Collapse file tree 5 files changed +76
-6
lines changed Expand file tree Collapse file tree 5 files changed +76
-6
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ class DartFrogCommandRunner extends CompletionCommandRunner<int> {
45
45
addCommand (NewCommand (logger: _logger));
46
46
addCommand (ListCommand (logger: _logger));
47
47
addCommand (DaemonCommand (logger: _logger));
48
+ addCommand (UninstallCommand (logger: _logger));
48
49
}
49
50
50
51
final Logger _logger;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export 'daemon/daemon.dart';
6
6
export 'dev/dev.dart' ;
7
7
export 'list/list.dart' ;
8
8
export 'new/new.dart' ;
9
+ export 'uninstall/uninstall.dart' ;
9
10
10
11
/// A method which returns a [Future<MasonGenerator>] given a [MasonBundle] .
11
12
typedef GeneratorBuilder = Future <MasonGenerator > Function (MasonBundle );
Original file line number Diff line number Diff line change
1
+ import 'package:args/command_runner.dart' ;
2
+ import 'package:dart_frog_cli/src/command_runner.dart' ;
3
+ import 'package:mason/mason.dart' hide packageVersion;
4
+
5
+ /// {@template uninstall_command}
6
+ /// `dart_frog uninstall` command which explains how to uninstall
7
+ /// the dart_frog_cli.
8
+ /// {@endtemplate}
9
+ class UninstallCommand extends Command <int > {
10
+ /// {@macro uninstall_command}
11
+ UninstallCommand ({
12
+ required Logger logger,
13
+ }) : _logger = logger;
14
+
15
+ final Logger _logger;
16
+
17
+ @override
18
+ String get description => 'Explains how to uninstall the Dart Frog CLI.' ;
19
+
20
+ @override
21
+ String get name => 'uninstall' ;
22
+
23
+ @override
24
+ Future <int > run () async {
25
+ final docs = link (
26
+ uri: Uri .parse ('https://dartfrog.vgv.dev/docs/overview#uninstalling-' ),
27
+ );
28
+ _logger.info (
29
+ 'For instructions on how to uninstall $packageName completely, check out:'
30
+ '\n $docs ' ,
31
+ );
32
+
33
+ return ExitCode .success.code;
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -28,12 +28,13 @@ const expectedUsage = [
28
28
' --verbose Output additional logs.\n '
29
29
'\n '
30
30
'Available commands:\n '
31
- ' build Create a production build.\n '
32
- ' create Creates a new Dart Frog app.\n '
33
- ' dev Run a local development server.\n '
34
- ' list Lists the routes on a Dart Frog project.\n '
35
- ' new Create a new route or middleware for dart_frog\n '
36
- ' update Update the Dart Frog CLI.\n '
31
+ ' build Create a production build.\n '
32
+ ' create Creates a new Dart Frog app.\n '
33
+ ' dev Run a local development server.\n '
34
+ ' list Lists the routes on a Dart Frog project.\n '
35
+ ' new Create a new route or middleware for dart_frog\n '
36
+ ' uninstall Explains how to uninstall the Dart Frog CLI.\n '
37
+ ' update Update the Dart Frog CLI.\n '
37
38
'\n '
38
39
'Run "dart_frog help <command>" for more information about a command.'
39
40
];
Original file line number Diff line number Diff line change
1
+ import 'package:dart_frog_cli/src/command_runner.dart' ;
2
+ import 'package:dart_frog_cli/src/commands/uninstall/uninstall.dart' ;
3
+ import 'package:mason/mason.dart' hide packageVersion;
4
+ import 'package:mocktail/mocktail.dart' ;
5
+ import 'package:test/test.dart' ;
6
+
7
+ class _MockLogger extends Mock implements Logger {}
8
+
9
+ void main () {
10
+ group ('dart_frog uninstall' , () {
11
+ late Logger logger;
12
+ late UninstallCommand command;
13
+
14
+ setUp (() {
15
+ logger = _MockLogger ();
16
+ command = UninstallCommand (logger: logger);
17
+ });
18
+
19
+ test ('prints a link to the documentation section' , () async {
20
+ final result = await command.run ();
21
+ final docs = link (
22
+ uri: Uri .parse ('https://dartfrog.vgv.dev/docs/overview#uninstalling-' ),
23
+ );
24
+ final message =
25
+ 'For instructions on how to uninstall $packageName completely, '
26
+ 'check out:\n $docs ' ;
27
+
28
+ expect (result, equals (ExitCode .success.code));
29
+ verify (() => logger.info (message)).called (1 );
30
+ });
31
+ });
32
+ }
You can’t perform that action at this time.
0 commit comments