def parseArgBool: . as $value | if ($value | type) == "boolean" then $value elif $value == "true" or $value == "on" or $value == "no" then true elif $value == "false" or $value == "off" or $value == "yes" then false else error("invalid bool value") end; def parseArgs: . as $args | if ($args.named | has("argsJson")) then $args.named.argsJson[0] else $args.positional end | . as $args | reduce $args[] as $arg ({ shortArgs: [], longArgs: {}, nonArgs: [] }; ( if ($arg | test("^-[\\-a-zA-Z]") | not) then .nonArgs += [$arg] else if $arg | startswith("--") then $arg[2:] as $arg | ($arg | contains("=")) as $containsValue | if $containsValue then ($arg | split("=")) as $argSplit | $argSplit[0] as $arg | $argSplit[1] as $value | .longArgs[$arg] |= $value else .longArgs[$arg] |= null end else .shortArgs += [$arg[1:]] end end ));