chore: cleaner CLI

Related: #459
This commit is contained in:
CosminPerRam 2024-01-16 02:14:02 +02:00
parent a8bc3aa098
commit 17691b54c0

View file

@ -27,23 +27,12 @@ if (argv._.length >= 1) {
const target = argv._[0]
const split = target.split(':')
options.host = split[0]
if (split.length >= 2) {
if (split.length > 1) {
options.port = split[1]
}
}
const applyBoolean = (value, fieldName, defaultValue = true) => {
if (value) {
options[fieldName] = defaultValue
}
}
const { debug, pretty, givenPortOnly, requestRulesRequired, requestPlayersRequired } = argv
applyBoolean(debug, 'debug')
applyBoolean(givenPortOnly, 'givenPortOnly')
applyBoolean(requestRulesRequired, 'requestRulesRequired')
applyBoolean(requestPlayersRequired, 'requestPlayersRequired')
const { debug, pretty } = options
const printOnPretty = (object) => {
if (!!pretty || debug) {