Files
speckle-server/packages/server/modules/cli/index.js
T
Kristaps Fabians Geikins b966f20fdb refactor(server): typescript support (#874)
Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
2022-08-04 14:21:39 +02:00

29 lines
781 B
JavaScript

const path = require('path')
const yargs = require('yargs')
require('../../bootstrap')
const execution = yargs
.scriptName('yarn cli')
.usage('$0 <cmd> [args]')
.commandDir(path.resolve(__dirname, './commands'), { extensions: ['js', 'ts'] })
.demandCommand()
.fail((msg, err, yargs) => {
if (!err) {
// If validation error (no err instance) then just show help and show the message
console.error(yargs.help())
console.error('\n', msg)
} else {
// If actual app error occurred, show the msg, but don't show help info
console.error(err)
console.error('\n', 'Specify --help for available options')
}
process.exit(1)
})
.help().argv
const promise = Promise.resolve(execution)
promise.then(() => {
yargs.exit(0)
})