run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
void run() async {
List<String> words = argResults!.rest;
showUsage(words.isEmpty, () => printUsage());
final String hashType = argResults!['type'];
final String expectedHash = words[0];
final String filePath = words[1];
final Hash hasher = _supportedHashes[hashType]!;
final file = File(filePath);
var checksum = Checksum();
final bool result = await checksum.check(file, hasher, expectedHash);
if (result) {
out('{@green}✅ Checksum is correct:{@end} {@green}$expectedHash{@end}');
} else {
out('{@red}⛔ Checksum is incorrect{@end}: {@yellow}$expectedHash{@end} != {@green}${checksum.fileHash}{@end}');
}
}