run method

  1. @override
void run()
override

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> args = argResults!.rest;

  showUsage(args.isEmpty, () => printUsage());

  final filePath = args[0];

  final run = Run();
  final marked = await run.asExec(filePath);

  if (!marked) {
    out("{@red}Failed to mark '$filePath' as executable{@end}");
    exit(cantExecute);
  }

  if (argResults!['verbose']) {
    out("{@green}File marked as executable: '$filePath'{@end}");
  }

  print(File(filePath).absolute.path);
  exit(success);
}