diff --git a/.gitignore b/.gitignore index 4f8c4d5e..49ce72d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .dart_tool/ -.packages/ +.packages pubspec.lock diff --git a/lib/src/executables/dart2_upgrade.dart b/lib/src/executables/dart2_upgrade.dart index 56ed34b1..8e66bbc9 100644 --- a/lib/src/executables/dart2_upgrade.dart +++ b/lib/src/executables/dart2_upgrade.dart @@ -14,6 +14,7 @@ import 'dart:io'; +import 'package:args/args.dart'; import 'package:codemod/codemod.dart'; import 'package:path/path.dart' as p; @@ -36,6 +37,14 @@ import '../ignoreable.dart'; import '../util.dart'; const _backwardsCompatFlag = '--backwards-compat'; +const _helpFlag = '--help'; +const _helpFlagAbbr = '-h'; +const _changesRequiredOutput = """ +To update your code, switch to Dart 2.1.0 and run the following commands: + pub global activate over_react_codemod ^1.0.1 + pub global run over_react_codemod:dart2_upgrade --backwards-compat +Then, review and commit the changes. +"""; void main(List args) { // Whether or not backwards-compatibility (with Dart 1) is desired will @@ -61,9 +70,13 @@ void main(List args) { ), args: args, defaultYes: true, + additionalHelpOutput: argParser.usage, + changesRequiredOutput: _changesRequiredOutput, ); - if (exitCode > 0) { + if (exitCode > 0 || + args.contains(_helpFlag) || + args.contains(_helpFlagAbbr)) { return; } @@ -113,5 +126,13 @@ void main(List args) { ], args: args, defaultYes: true, + changesRequiredOutput: _changesRequiredOutput, ); } + +final argParser = ArgParser() + ..addFlag( + 'backwards-compat', + negatable: false, + help: 'Maintain backwards-compatibility with Dart 1.', + ); diff --git a/pubspec.yaml b/pubspec.yaml index 4b543040..ea14ba46 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,7 @@ environment: dependencies: analyzer: ^0.33.6+1 args: ^1.5.1 - codemod: ^0.1.2 + codemod: ^0.1.3 path: ^1.6.2 pub_semver: ^1.4.2 source_span: ^1.4.1 @@ -33,4 +33,4 @@ dev_dependencies: test: ^1.5.1 executables: - dart2_upgrade: + dart2_upgrade: \ No newline at end of file