From 5ddf6fa352c21112781ba559ef179b24c16985e0 Mon Sep 17 00:00:00 2001 From: pq Date: Wed, 1 Sep 2021 09:55:39 -0700 Subject: [PATCH 1/2] make outdir optional --- tool/rule.dart | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tool/rule.dart b/tool/rule.dart index 23c6971f6..ce358400d 100644 --- a/tool/rule.dart +++ b/tool/rule.dart @@ -14,8 +14,12 @@ import '../test/test_constants.dart'; void main(List 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 { @@ -25,14 +29,11 @@ void main(List 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']; From 55d090b4ac4973f7e4137680774f67242d45cbb5 Mon Sep 17 00:00:00 2001 From: pq Date: Wed, 1 Sep 2021 11:22:37 -0700 Subject: [PATCH 2/2] remove unnecessary cast --- tool/rule.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/rule.dart b/tool/rule.dart index ce358400d..fdc6476b5 100644 --- a/tool/rule.dart +++ b/tool/rule.dart @@ -44,7 +44,7 @@ void main(List 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();