Files
speckle-server/packages/server/modules/cli/index.js
T
Iain Sproat 4d01e13a84 feat(structured logging) (#1242)
* Revert "Revert structured logging 2 (#1240)"
This reverts commit 78ecaeffcb.
* Logging should not be bundled into core shared directory
* making sure observability stuff isnt bundled into frontend


Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2022-12-06 11:51:18 +00:00

30 lines
825 B
JavaScript

const path = require('path')
const yargs = require('yargs')
require('../../bootstrap')
const { logger } = require('@/logging/logging')
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
logger.error(yargs.help())
logger.error('\n', msg)
} else {
// If actual app error occurred, show the msg, but don't show help info
logger.error(err)
logger.error('\n', 'Specify --help for available options')
}
process.exit(1)
})
.help().argv
const promise = Promise.resolve(execution)
promise.then(() => {
yargs.exit(0)
})