run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
Future run() async {
if (argResults!.rest.isEmpty) {
print('Must provide file path');
return;
}
var filePath = argResults!.rest[0];
var rawData = File(filePath).readAsBytesSync();
var gitRootDir = GitRepository.findRootDir(Directory.current.path)!;
var repo = await GitRepository.load(gitRootDir);
var fmt = argResults!['type'] as String;
var objRes = createObject(fmt, rawData);
var obj = objRes.get();
GitHash hash;
if (argResults!['write'] as bool) {
hash = await repo.objStorage.writeObject(obj);
} else {
hash = obj.hash;
}
print(hash);
}