diff options
Diffstat (limited to 'std/flags')
-rwxr-xr-x | std/flags/all_bool_test.ts | 8 | ||||
-rwxr-xr-x | std/flags/bool_test.ts | 42 | ||||
-rwxr-xr-x | std/flags/dash_test.ts | 2 | ||||
-rwxr-xr-x | std/flags/default_bool_test.ts | 8 | ||||
-rwxr-xr-x | std/flags/dotted_test.ts | 2 | ||||
-rwxr-xr-x | std/flags/long_test.ts | 4 | ||||
-rw-r--r-- | std/flags/mod.ts | 12 | ||||
-rwxr-xr-x | std/flags/num_test.ts | 4 | ||||
-rwxr-xr-x | std/flags/parse_test.ts | 28 | ||||
-rwxr-xr-x | std/flags/short_test.ts | 8 | ||||
-rwxr-xr-x | std/flags/stop_early_test.ts | 4 | ||||
-rwxr-xr-x | std/flags/unknown_test.ts | 14 |
12 files changed, 68 insertions, 68 deletions
diff --git a/std/flags/all_bool_test.ts b/std/flags/all_bool_test.ts index 6516f48ed..cb5a36710 100755 --- a/std/flags/all_bool_test.ts +++ b/std/flags/all_bool_test.ts @@ -5,12 +5,12 @@ import { parse } from "./mod.ts"; // flag boolean true (default all --args to boolean) Deno.test(function flagBooleanTrue(): void { const argv = parse(["moo", "--honk", "cow"], { - boolean: true + boolean: true, }); assertEquals(argv, { honk: true, - _: ["moo", "cow"] + _: ["moo", "cow"], }); assertEquals(typeof argv.honk, "boolean"); @@ -19,14 +19,14 @@ Deno.test(function flagBooleanTrue(): void { // flag boolean true only affects double hyphen arguments without equals signs Deno.test(function flagBooleanTrueOnlyAffectsDoubleDash(): void { const argv = parse(["moo", "--honk", "cow", "-p", "55", "--tacos=good"], { - boolean: true + boolean: true, }); assertEquals(argv, { honk: true, tacos: "good", p: 55, - _: ["moo", "cow"] + _: ["moo", "cow"], }); assertEquals(typeof argv.honk, "boolean"); diff --git a/std/flags/bool_test.ts b/std/flags/bool_test.ts index 2d6a8b938..f2d88e617 100755 --- a/std/flags/bool_test.ts +++ b/std/flags/bool_test.ts @@ -5,13 +5,13 @@ import { parse } from "./mod.ts"; Deno.test(function flagBooleanDefaultFalse(): void { const argv = parse(["moo"], { boolean: ["t", "verbose"], - default: { verbose: false, t: false } + default: { verbose: false, t: false }, }); assertEquals(argv, { verbose: false, t: false, - _: ["moo"] + _: ["moo"], }); assertEquals(typeof argv.verbose, "boolean"); @@ -20,14 +20,14 @@ Deno.test(function flagBooleanDefaultFalse(): void { Deno.test(function booleanGroups(): void { const argv = parse(["-x", "-z", "one", "two", "three"], { - boolean: ["x", "y", "z"] + boolean: ["x", "y", "z"], }); assertEquals(argv, { x: true, y: false, z: true, - _: ["one", "two", "three"] + _: ["one", "two", "three"], }); assertEquals(typeof argv.x, "boolean"); @@ -40,16 +40,16 @@ Deno.test(function booleanAndAliasWithChainableApi(): void { const regular = ["--herp", "derp"]; const aliasedArgv = parse(aliased, { boolean: "herp", - alias: { h: "herp" } + alias: { h: "herp" }, }); const propertyArgv = parse(regular, { boolean: "herp", - alias: { h: "herp" } + alias: { h: "herp" }, }); const expected = { herp: true, h: true, - _: ["derp"] + _: ["derp"], }; assertEquals(aliasedArgv, expected); @@ -61,14 +61,14 @@ Deno.test(function booleanAndAliasWithOptionsHash(): void { const regular = ["--herp", "derp"]; const opts = { alias: { h: "herp" }, - boolean: "herp" + boolean: "herp", }; const aliasedArgv = parse(aliased, opts); const propertyArgv = parse(regular, opts); const expected = { herp: true, h: true, - _: ["derp"] + _: ["derp"], }; assertEquals(aliasedArgv, expected); assertEquals(propertyArgv, expected); @@ -80,7 +80,7 @@ Deno.test(function booleanAndAliasArrayWithOptionsHash(): void { const alt = ["--harp", "derp"]; const opts = { alias: { h: ["herp", "harp"] }, - boolean: "h" + boolean: "h", }; const aliasedArgv = parse(aliased, opts); const propertyArgv = parse(regular, opts); @@ -89,7 +89,7 @@ Deno.test(function booleanAndAliasArrayWithOptionsHash(): void { harp: true, herp: true, h: true, - _: ["derp"] + _: ["derp"], }; assertEquals(aliasedArgv, expected); assertEquals(propertyArgv, expected); @@ -101,14 +101,14 @@ Deno.test(function booleanAndAliasUsingExplicitTrue(): void { const regular = ["--herp", "true"]; const opts = { alias: { h: "herp" }, - boolean: "h" + boolean: "h", }; const aliasedArgv = parse(aliased, opts); const propertyArgv = parse(regular, opts); const expected = { herp: true, h: true, - _: [] + _: [], }; assertEquals(aliasedArgv, expected); @@ -119,14 +119,14 @@ Deno.test(function booleanAndAliasUsingExplicitTrue(): void { // boolean and --x=true Deno.test(function booleanAndNonBoolean(): void { const parsed = parse(["--boool", "--other=true"], { - boolean: "boool" + boolean: "boool", }); assertEquals(parsed.boool, true); assertEquals(parsed.other, "true"); const parsed2 = parse(["--boool", "--other=false"], { - boolean: "boool" + boolean: "boool", }); assertEquals(parsed2.boool, true); @@ -136,9 +136,9 @@ Deno.test(function booleanAndNonBoolean(): void { Deno.test(function booleanParsingTrue(): void { const parsed = parse(["--boool=true"], { default: { - boool: false + boool: false, }, - boolean: ["boool"] + boolean: ["boool"], }); assertEquals(parsed.boool, true); @@ -147,9 +147,9 @@ Deno.test(function booleanParsingTrue(): void { Deno.test(function booleanParsingFalse(): void { const parsed = parse(["--boool=false"], { default: { - boool: true + boool: true, }, - boolean: ["boool"] + boolean: ["boool"], }); assertEquals(parsed.boool, false); @@ -187,7 +187,7 @@ Deno.test(function latestFlagIsBooleanNegation(): void { assertEquals(parsed.foo, false); const parsed2 = parse(["--no-foo", "--foo", "--no-foo", "123"], { - boolean: ["foo"] + boolean: ["foo"], }); assertEquals(parsed2.foo, false); }); @@ -197,7 +197,7 @@ Deno.test(function latestFlagIsBoolean(): void { assertEquals(parsed.foo, true); const parsed2 = parse(["--foo", "--no-foo", "--foo", "123"], { - boolean: ["foo"] + boolean: ["foo"], }); assertEquals(parsed2.foo, true); }); diff --git a/std/flags/dash_test.ts b/std/flags/dash_test.ts index bdf8f502d..3df169291 100755 --- a/std/flags/dash_test.ts +++ b/std/flags/dash_test.ts @@ -22,7 +22,7 @@ Deno.test(function moveArgsAfterDoubleDashIntoOwnArray(): void { { name: "John", _: ["before"], - "--": ["after"] + "--": ["after"], } ); }); diff --git a/std/flags/default_bool_test.ts b/std/flags/default_bool_test.ts index 813b6870b..4376038fe 100755 --- a/std/flags/default_bool_test.ts +++ b/std/flags/default_bool_test.ts @@ -5,7 +5,7 @@ import { parse } from "./mod.ts"; Deno.test(function booleanDefaultTrue(): void { const argv = parse([], { boolean: "sometrue", - default: { sometrue: true } + default: { sometrue: true }, }); assertEquals(argv.sometrue, true); }); @@ -13,7 +13,7 @@ Deno.test(function booleanDefaultTrue(): void { Deno.test(function booleanDefaultFalse(): void { const argv = parse([], { boolean: "somefalse", - default: { somefalse: false } + default: { somefalse: false }, }); assertEquals(argv.somefalse, false); }); @@ -21,12 +21,12 @@ Deno.test(function booleanDefaultFalse(): void { Deno.test(function booleanDefaultNull(): void { const argv = parse([], { boolean: "maybe", - default: { maybe: null } + default: { maybe: null }, }); assertEquals(argv.maybe, null); const argv2 = parse(["--maybe"], { boolean: "maybe", - default: { maybe: null } + default: { maybe: null }, }); assertEquals(argv2.maybe, true); }); diff --git a/std/flags/dotted_test.ts b/std/flags/dotted_test.ts index 93dd3031f..c86392f2a 100755 --- a/std/flags/dotted_test.ts +++ b/std/flags/dotted_test.ts @@ -5,7 +5,7 @@ import { parse } from "./mod.ts"; Deno.test(function dottedAlias(): void { const argv = parse(["--a.b", "22"], { default: { "a.b": 11 }, - alias: { "a.b": "aa.bb" } + alias: { "a.b": "aa.bb" }, }); assertEquals(argv.a.b, 22); assertEquals(argv.aa.bb, 22); diff --git a/std/flags/long_test.ts b/std/flags/long_test.ts index e5b68f8c0..f0f4d7545 100755 --- a/std/flags/long_test.ts +++ b/std/flags/long_test.ts @@ -9,11 +9,11 @@ Deno.test(function longOpts(): void { assertEquals(parse(["--host", "localhost", "--port", "555"]), { host: "localhost", port: 555, - _: [] + _: [], }); assertEquals(parse(["--host=localhost", "--port=555"]), { host: "localhost", port: 555, - _: [] + _: [], }); }); diff --git a/std/flags/mod.ts b/std/flags/mod.ts index 18727a665..b334cb5b8 100644 --- a/std/flags/mod.ts +++ b/std/flags/mod.ts @@ -85,7 +85,7 @@ function isNumber(x: unknown): boolean { function hasKey(obj: NestedMapping, keys: string[]): boolean { let o = obj; - keys.slice(0, -1).forEach(key => { + keys.slice(0, -1).forEach((key) => { o = (get(o, key) ?? {}) as NestedMapping; }); @@ -107,14 +107,14 @@ export function parse( default: defaults = {}, stopEarly = false, string = [], - unknown = (i: unknown): unknown => i + unknown = (i: unknown): unknown => i, }: ArgParsingOptions = {} ): Args { const flags: Flags = { bools: {}, strings: {}, unknownFn: unknown, - allBools: false + allBools: false, }; if (boolean !== undefined) { @@ -139,7 +139,7 @@ export function parse( aliases[key] = val; } for (const alias of getForce(aliases, key)) { - aliases[alias] = [key].concat(aliases[key].filter(y => alias !== y)); + aliases[alias] = [key].concat(aliases[key].filter((y) => alias !== y)); } } } @@ -171,7 +171,7 @@ export function parse( function setKey(obj: NestedMapping, keys: string[], value: unknown): void { let o = obj; - keys.slice(0, -1).forEach(function(key): void { + keys.slice(0, -1).forEach(function (key): void { if (get(o, key) === undefined) { o[key] = {}; } @@ -214,7 +214,7 @@ export function parse( function aliasIsBoolean(key: string): boolean { return getForce(aliases, key).some( - x => typeof get(flags.bools, x) === "boolean" + (x) => typeof get(flags.bools, x) === "boolean" ); } diff --git a/std/flags/num_test.ts b/std/flags/num_test.ts index 0d6b634b9..f8a0d11ac 100755 --- a/std/flags/num_test.ts +++ b/std/flags/num_test.ts @@ -14,7 +14,7 @@ Deno.test(function nums(): void { "10f", "--hex", "0xdeadbeef", - "789" + "789", ]); assertEquals(argv, { x: 1234, @@ -22,7 +22,7 @@ Deno.test(function nums(): void { z: 1e7, w: "10f", hex: 0xdeadbeef, - _: [789] + _: [789], }); assertEquals(typeof argv.x, "number"); assertEquals(typeof argv.y, "number"); diff --git a/std/flags/parse_test.ts b/std/flags/parse_test.ts index cd93c1f81..abba42e16 100755 --- a/std/flags/parse_test.ts +++ b/std/flags/parse_test.ts @@ -6,7 +6,7 @@ Deno.test(function parseArgs(): void { assertEquals(parse(["--no-moo"]), { moo: false, _: [] }); assertEquals(parse(["-v", "a", "-v", "b", "-v", "c"]), { v: ["a", "b", "c"], - _: [] + _: [], }); }); @@ -28,7 +28,7 @@ Deno.test(function comprehensive(): void { "--multi=baz", "--", "--not-a-flag", - "eek" + "eek", ]), { c: true, @@ -42,7 +42,7 @@ Deno.test(function comprehensive(): void { multi: ["quux", "baz"], meep: false, name: "meowmers", - _: ["bare", "--not-a-flag", "eek"] + _: ["bare", "--not-a-flag", "eek"], } ); }); @@ -56,13 +56,13 @@ Deno.test(function flagBoolean(): void { Deno.test(function flagBooleanValue(): void { const argv = parse(["--verbose", "false", "moo", "-t", "true"], { boolean: ["t", "verbose"], - default: { verbose: true } + default: { verbose: true }, }); assertEquals(argv, { verbose: false, t: true, - _: ["moo"] + _: ["moo"], }); assertEquals(typeof argv.verbose, "boolean"); @@ -110,7 +110,7 @@ Deno.test(function emptyStrings(): void { assertEquals(typeof str, "string"); const letters = parse(["-art"], { - string: ["a", "t"] + string: ["a", "t"], }); assertEquals(letters.a, ""); @@ -121,7 +121,7 @@ Deno.test(function emptyStrings(): void { Deno.test(function stringAndAlias(): void { const x = parse(["--str", "000123"], { string: "s", - alias: { s: "str" } + alias: { s: "str" }, }); assertEquals(x.str, "000123"); @@ -131,7 +131,7 @@ Deno.test(function stringAndAlias(): void { const y = parse(["-s", "000123"], { string: "str", - alias: { str: "s" } + alias: { str: "s" }, }); assertEquals(y.str, "000123"); @@ -146,13 +146,13 @@ Deno.test(function slashBreak(): void { x: true, y: true, z: "/foo/bar/baz", - _: [] + _: [], }); }); Deno.test(function alias(): void { const argv = parse(["-f", "11", "--zoom", "55"], { - alias: { z: "zoom" } + alias: { z: "zoom" }, }); assertEquals(argv.zoom, 55); assertEquals(argv.z, argv.zoom); @@ -161,7 +161,7 @@ Deno.test(function alias(): void { Deno.test(function multiAlias(): void { const argv = parse(["-f", "11", "--zoom", "55"], { - alias: { z: ["zm", "zoom"] } + alias: { z: ["zm", "zoom"] }, }); assertEquals(argv.zoom, 55); assertEquals(argv.z, argv.zoom); @@ -178,7 +178,7 @@ Deno.test(function nestedDottedObjects(): void { "--foo.quux.quibble", "5", "--foo.quux.oO", - "--beep.boop" + "--beep.boop", ]); assertEquals(argv.foo, { @@ -186,8 +186,8 @@ Deno.test(function nestedDottedObjects(): void { baz: 4, quux: { quibble: 5, - oO: true - } + oO: true, + }, }); assertEquals(argv.beep, { boop: true }); }); diff --git a/std/flags/short_test.ts b/std/flags/short_test.ts index d7171b920..6305bbb94 100755 --- a/std/flags/short_test.ts +++ b/std/flags/short_test.ts @@ -16,13 +16,13 @@ Deno.test(function short(): void { a: true, t: true, s: "meow", - _: [] + _: [], }); assertEquals(parse(["-h", "localhost"]), { h: "localhost", _: [] }); assertEquals(parse(["-h", "localhost", "-p", "555"]), { h: "localhost", p: 555, - _: [] + _: [], }); }); @@ -31,7 +31,7 @@ Deno.test(function mixedShortBoolAndCapture(): void { f: true, p: 555, h: "localhost", - _: ["script.js"] + _: ["script.js"], }); }); @@ -40,6 +40,6 @@ Deno.test(function shortAndLong(): void { f: true, p: 555, h: "localhost", - _: ["script.js"] + _: ["script.js"], }); }); diff --git a/std/flags/stop_early_test.ts b/std/flags/stop_early_test.ts index d1996e7aa..4b7eac097 100755 --- a/std/flags/stop_early_test.ts +++ b/std/flags/stop_early_test.ts @@ -5,11 +5,11 @@ import { parse } from "./mod.ts"; // stops parsing on the first non-option when stopEarly is set Deno.test(function stopParsing(): void { const argv = parse(["--aaa", "bbb", "ccc", "--ddd"], { - stopEarly: true + stopEarly: true, }); assertEquals(argv, { aaa: "bbb", - _: ["ccc", "--ddd"] + _: ["ccc", "--ddd"], }); }); diff --git a/std/flags/unknown_test.ts b/std/flags/unknown_test.ts index acbb131ee..90c638b67 100755 --- a/std/flags/unknown_test.ts +++ b/std/flags/unknown_test.ts @@ -13,7 +13,7 @@ Deno.test(function booleanAndAliasIsNotUnknown(): void { const opts = { alias: { h: "herp" }, boolean: "h", - unknown: unknownFn + unknown: unknownFn, }; parse(aliased, opts); parse(regular, opts); @@ -29,12 +29,12 @@ Deno.test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void { } const argv = parse(["--honk", "--tacos=good", "cow", "-p", "55"], { boolean: true, - unknown: unknownFn + unknown: unknownFn, }); assertEquals(unknown, ["--tacos=good", "cow", "-p"]); assertEquals(argv, { honk: true, - _: [] + _: [], }); }); @@ -49,7 +49,7 @@ Deno.test(function stringAndAliasIsNotUnkown(): void { const opts = { alias: { h: "herp" }, string: "h", - unknown: unknownFn + unknown: unknownFn, }; parse(aliased, opts); parse(regular, opts); @@ -68,7 +68,7 @@ Deno.test(function defaultAndAliasIsNotUnknown(): void { const opts = { default: { h: "bar" }, alias: { h: "herp" }, - unknown: unknownFn + unknown: unknownFn, }; parse(aliased, opts); parse(regular, opts); @@ -85,13 +85,13 @@ Deno.test(function valueFollowingDoubleHyphenIsNotUnknown(): void { const aliased = ["--bad", "--", "good", "arg"]; const opts = { "--": true, - unknown: unknownFn + unknown: unknownFn, }; const argv = parse(aliased, opts); assertEquals(unknown, ["--bad"]); assertEquals(argv, { "--": ["good", "arg"], - _: [] + _: [], }); }); |