1 import * as program from 'commander'
3 import { database as db } from '../server/initializers/database'
6 .option('-u, --user [user]', 'User')
9 if (program.user === undefined) {
10 console.error('All parameters are mandatory.')
16 return db.User.loadByUsername(program.user)
20 console.error('User unknown.')
24 const readline = require('readline')
25 const Writable = require('stream').Writable
26 const mutableStdout = new Writable({
27 write: function (chunk, encoding, callback) {
31 const rl = readline.createInterface({
33 output: mutableStdout,
37 console.log('New password?')
38 rl.on('line', function (password) {
39 user.password = password
42 .then(() => console.log('User password updated.'))
43 .catch(err => console.error(err))
44 .finally(() => process.exit(0))