run method

  1. @override
Future<int> run()
inherited

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<int> run() => withApp((app) async {
  final [id, roleName] = argResults!.rest.length == 2
      ? argResults!.rest
      : (throw UsageException('Expected <model-id> <role>.', usage));
  final role = await Role.findByName(roleName, guard: _guard(this));
  await apply(argResults!['model'] as String, int.tryParse(id) ?? id, role);
  await PermissionRegistrar.current.forgetCachedPermissions();
  stdout.writeln('Done.');
  return 0;
});