Skip to content

Commit f7d0955

Browse files
committed
command —f option and output formatting
1 parent 2500b62 commit f7d0955

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Commands/UpdateRolePermissionsCommand.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protected function configure()
1414
{
1515
$this->setName('auth:update-role-permissions')
1616
->setDescription('Updates Roles and Permissions according to a definitions specified in the application. Useful if the application does not allow users to customise role permissions.')
17-
->addArgument('force');
17+
->addOption('f', null, null, 'Forces update - does not prompt user');
1818

1919
parent::configure();
2020
}
@@ -23,21 +23,27 @@ protected function executeWithConnection(InputInterface $input, OutputInterface
2323
{
2424
$helper = $this->getHelper('question');
2525

26-
$force = $input->getArgument('force') === '-f';
26+
$force = $input->getOption('f');
2727

28+
if (!$force) {
29+
$output->writeln('<comment>Warning: New roles may be created, and all permissions associated with a role may be updated/removed if not specified in RolePermissionDefinitions.</comment>');
30+
}
2831
$verify = new Question(
29-
'Warning: New roles may be created, and all permissions associated with a role may be updated/removed if not specified in RolePermissionDefinitions. Are you sure you want to proceed? [y/n] '
32+
'<question>Are you sure you want to proceed? [y/n] </question>'
3033
);
3134
$verify->setValidator(function ($value) use ($output) {
3235
if (stripos($value, 'y') !== 0) {
33-
$output->writeln('Aborted');
36+
$output->writeln('<error>Aborted</error>');
3437
return false;
3538
}
3639
return true;
3740
});
3841
if ($force || $helper->ask($input, $output, $verify)) {
42+
if (!$force) {
43+
$output->writeln('<comment>If you would like to suppress user verification in the future, use the --f option</comment>');
44+
}
3945
AuthenticationWithRolesModule::updateRolePermissions();
40-
$output->writeln('Role Permissions Updated');
46+
$output->writeln('<info>Role Permissions Updated</info>');
4147
}
4248
}
4349
}

0 commit comments

Comments
 (0)