Skip to content

Commit

Permalink
Merge pull request #21 from smaifullerton-wk/cplat-4058-more-helpful-…
Browse files Browse the repository at this point in the history
…stderr

CPLAT-4058 Provide additional --help output and better stderr
  • Loading branch information
rmconsole6-wk authored Feb 6, 2019
2 parents 7f753f4 + 8e97b96 commit f347f6c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.dart_tool/
.packages/
.packages
pubspec.lock
23 changes: 22 additions & 1 deletion lib/src/executables/dart2_upgrade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import 'dart:io';

import 'package:args/args.dart';
import 'package:codemod/codemod.dart';
import 'package:path/path.dart' as p;

Expand All @@ -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<String> args) {
// Whether or not backwards-compatibility (with Dart 1) is desired will
Expand All @@ -61,9 +70,13 @@ void main(List<String> args) {
),
args: args,
defaultYes: true,
additionalHelpOutput: argParser.usage,
changesRequiredOutput: _changesRequiredOutput,
);

if (exitCode > 0) {
if (exitCode > 0 ||
args.contains(_helpFlag) ||
args.contains(_helpFlagAbbr)) {
return;
}

Expand Down Expand Up @@ -113,5 +126,13 @@ void main(List<String> args) {
],
args: args,
defaultYes: true,
changesRequiredOutput: _changesRequiredOutput,
);
}

final argParser = ArgParser()
..addFlag(
'backwards-compat',
negatable: false,
help: 'Maintain backwards-compatibility with Dart 1.',
);
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,4 +33,4 @@ dev_dependencies:
test: ^1.5.1

executables:
dart2_upgrade:
dart2_upgrade:

0 comments on commit f347f6c

Please sign in to comment.