diff --git a/src/argv.ts b/src/argv.ts new file mode 100644 index 0000000000..da22e5fdfc --- /dev/null +++ b/src/argv.ts @@ -0,0 +1,11 @@ +import * as program from 'commander'; +import * as pkg from '../package.json'; + +program + .version(pkg.version) + .option('--no-daemons', 'Disable daemon processes (for debbuging)') + .option('--disable-clustering', 'Disable clustering') + .option('--quiet', 'Suppress all logs') + .parse(process.argv); + +export { program }; diff --git a/src/index.ts b/src/index.ts index af9f7de983..ea8d67b77c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,6 @@ import chalk from 'chalk'; import * as portscanner from 'portscanner'; import * as isRoot from 'is-root'; import Xev from 'xev'; -import * as program from 'commander'; import * as sysUtils from 'systeminformation'; import mongo, { nativeDbConn } from './db/mongodb'; @@ -23,21 +22,13 @@ import loadConfig from './config/load'; import { Config } from './config/types'; import { lessThan } from './prelude/array'; import * as pkg from '../package.json'; +import { program } from './argv'; const logger = new Logger('core', 'cyan'); const bootLogger = logger.createSubLogger('boot', 'magenta'); const clusterLog = logger.createSubLogger('cluster', 'orange'); const ev = new Xev(); -//#region Command line argument definitions -program - .version(pkg.version) - .option('--no-daemons', 'Disable daemon processes (for debbuging)') - .option('--disable-clustering', 'Disable clustering') - .option('--quiet', 'Suppress all logs') - .parse(process.argv); -//#endregion - /** * Init process */ diff --git a/src/misc/logger.ts b/src/misc/logger.ts index 6d75e65ce4..15d2c84d70 100644 --- a/src/misc/logger.ts +++ b/src/misc/logger.ts @@ -1,8 +1,7 @@ import * as cluster from 'cluster'; import chalk from 'chalk'; import * as dateformat from 'dateformat'; - -const quiet = process.argv.find(x => x == '--quiet'); +import { program } from '../argv'; export default class Logger { private domain: string; @@ -21,7 +20,7 @@ export default class Logger { } public log(level: string, message: string, important = false): void { - if (quiet) return; + if (program.quiet) return; const domain = this.color ? chalk.keyword(this.color)(this.domain) : chalk.white(this.domain); if (this.parentLogger) { this.parentLogger.log(level, `[${domain}]\t${message}`, important);