Rename example/hasher.dart -> example/example.dart (#91)
Follows pub.dev convention – improves score
Also use correct exit code for error cases
Also use exitCode setter + return - recommended pattern which
does not break debugging
diff --git a/example/hash.dart b/example/example.dart
similarity index 80%
rename from example/hash.dart
rename to example/example.dart
index 8c6a92c..387c014 100644
--- a/example/hash.dart
+++ b/example/example.dart
@@ -12,7 +12,8 @@
Future main(List<String> args) async {
if (args == null || args.length != 2) {
print(_usage);
- exit(1);
+ exitCode = 64; // Command was used incorrectly.
+ return;
}
Hash hasher;
@@ -29,7 +30,8 @@
break;
default:
print(_usage);
- exit(1);
+ exitCode = 64; // Command was used incorrectly.
+ return;
}
var filename = args[1];
@@ -37,7 +39,8 @@
if (!input.existsSync()) {
print('File "$filename" does not exist.');
- exit(1);
+ exitCode = 66; // An input file did not exist or was not readable.
+ return;
}
var value = await hasher.bind(input.openRead()).first;