minor oncli accounts

This commit is contained in:
lesion 2022-07-27 12:06:06 +02:00
parent 4ac78db475
commit 6bda3574de
No known key found for this signature in database
GPG key ID: 352918250B012177

View file

@ -23,6 +23,12 @@ async function modify (args) {
await user.save() await user.save()
console.log(`New password for user ${user.email} is '${password}'`) console.log(`New password for user ${user.email} is '${password}'`)
} }
if (args.admin) {
user.is_admin = true
await user.save()
}
await db.close()
} }
async function create (args) { async function create (args) {
@ -71,13 +77,14 @@ const accountsCLI = yargs => yargs
'reset-password': { 'reset-password': {
describe: 'Resets the password of the given account ', describe: 'Resets the password of the given account ',
type: 'boolean' type: 'boolean'
} },
admin: { describe: 'Define this account as administrator', type: 'boolean' }
}, modify) }, modify)
.command('create <email|username>', 'Create an account', { .command('create <email|username> [admin]', 'Create an account', {
admin: { describe: 'Define this account as administrator', type: 'boolean' } admin: { describe: 'Define this account as administrator', type: 'boolean' }
}, create) }, create)
.positional('email', { describe: '', type: 'string', demandOption: true }) .command('remove <email|username>', 'Remove an account', {}, remove)
.command('remove <email|username>', 'Remove an account', {}, remove) .positional('email', { describe: 'account email or username', type: 'string', demandOption: true })
.recommendCommands() .recommendCommands()
.demandCommand(1, '') .demandCommand(1, '')
.argv .argv