mirror of
https://github.com/sbrl/terrain50-cli.git
synced 2024-11-22 06:53:01 +00:00
cli: add --log-level argument
This commit is contained in:
parent
1b92d523f6
commit
a5e2754cd8
1 changed files with 10 additions and 0 deletions
|
@ -7,6 +7,9 @@ import TOML from '@iarna/toml';
|
|||
|
||||
import CliParser from 'applause-cli';
|
||||
|
||||
import l from '../Helpers/Log.mjs';
|
||||
import { LOG_LEVELS } from '../Helpers/Log.mjs';
|
||||
|
||||
import a from '../Helpers/Ansi.mjs';
|
||||
import settings from './settings.mjs';
|
||||
|
||||
|
@ -57,6 +60,7 @@ async function get_actions_metadata() {
|
|||
export default async function() {
|
||||
let cli = new CliParser(path.resolve(__dirname, "../../package.json"));
|
||||
cli.set_description_extended(`With terrain50 ${await get_version()}`);
|
||||
cli.argument("log-level", "The logging level. Possible values: debug (default), info, log, warn, error, none", "debug", "string");
|
||||
cli.argument("tolerant", "When parsing streams of data, be more tolerant of whitespace inconsistencies and other errors at the cost of decreased performance (otherwise it is assumed a single space separates elements on a line).", false, "boolean");
|
||||
|
||||
// Disable ansi escape codes if requested
|
||||
|
@ -91,6 +95,12 @@ export default async function() {
|
|||
return;
|
||||
}
|
||||
|
||||
if(typeof LOG_LEVELS[settings.cli.log_level.toUpperCase()] == "undefined") {
|
||||
console.error(`${a.hicol}${a.fred}Error: Unknown log level '${settings.cli.log_level}' (possible values: debug, info, log, warn, error, none)`);
|
||||
process.exit(1);
|
||||
}
|
||||
l.level = LOG_LEVELS[settings.cli.log_level.toUpperCase()];
|
||||
|
||||
// 3: Environment Variable Parsing
|
||||
|
||||
// process.env.XYZ
|
||||
|
|
Loading…
Reference in a new issue