1
0
Fork 0
mirror of https://github.com/sbrl/terrain50-cli.git synced 2024-06-18 09:24:56 +00:00

cli: add --log-level argument

This commit is contained in:
Starbeamrainbowlabs 2021-01-25 18:24:25 +00:00
parent 1b92d523f6
commit a5e2754cd8
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -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