Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
make outdir optional (#2918)
Browse files Browse the repository at this point in the history
* make outdir optional

* remove unnecessary cast
  • Loading branch information
pq authored Sep 1, 2021
1 parent 1d17f27 commit 29e6e07
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tool/rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import '../test/test_constants.dart';
void main(List<String> args) {
var parser = ArgParser()
..addOption('out', abbr: 'o', help: 'Specifies project root.')
..addOption('name',
abbr: 'n', help: 'Specifies lower_underscore rule name.');
..addOption(
'name',
abbr: 'n',
help: 'Specifies lower_underscore rule name.',
mandatory: true,
);

ArgResults options;
try {
Expand All @@ -25,14 +29,11 @@ void main(List<String> args) {
return;
}

var outDir = options['out'];

if (outDir != null) {
var d = Directory(outDir as String);
if (!d.existsSync()) {
print("Directory '${d.path}' does not exist");
return;
}
var outDir = options['out'] ?? '.';
var d = Directory(outDir as String);
if (!d.existsSync()) {
print("Directory '${d.path}' does not exist");
return;
}

var ruleName = options['name'];
Expand All @@ -43,7 +44,7 @@ void main(List<String> args) {
}

// Generate rule stub.
generateRule(ruleName as String, outDir: outDir as String?);
generateRule(ruleName as String, outDir: outDir);
}

String get _thisYear => DateTime.now().year.toString();
Expand Down

0 comments on commit 29e6e07

Please sign in to comment.