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

make outdir optional #2918

Merged
merged 2 commits into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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