minor with cli

This commit is contained in:
lesion
2022-05-05 11:12:53 +02:00
parent 09df023848
commit 282b638928

View File

@@ -26,6 +26,7 @@ async function modify (args) {
} }
async function add (args) { async function add (args) {
} }
async function list () { async function list () {
@@ -33,7 +34,7 @@ async function list () {
const User = require('../api/models/user') const User = require('../api/models/user')
const users = await User.findAll() const users = await User.findAll()
console.log() console.log()
users.forEach(u => console.log(`${u.id}\tadmin: ${u.is_admin}\tenabled: ${u.is_active}\temail: ${u.email} - ${u.password}`)) users.forEach(u => console.log(`${u.id}\tadmin: ${u.is_admin}\tenabled: ${u.is_active}\temail: ${u.email}`))
console.log() console.log()
} }
@@ -42,13 +43,19 @@ const accountsCLI = yargs => {
.command('list', 'List all accounts', list) .command('list', 'List all accounts', list)
.command('modify', 'Modify', { .command('modify', 'Modify', {
account: { account: {
describe: 'Account to modify' describe: 'Account to modify',
type: 'string',
demandOption: true
}, },
'reset-password': { 'reset-password': {
describe: 'Resets the password of the given accoun ' describe: 'Resets the password of the given accoun ',
type: 'boolean'
} }
}, modify) }, modify)
.command('add', 'Add an account', {}, add) .command('add', 'Add an account', {}, add)
.recommendCommands()
.strict()
.demandCommand(1, '')
} }
module.exports = accountsCLI module.exports = accountsCLI