diff options
Diffstat (limited to 'std/flags')
-rw-r--r-- | std/flags/README.md | 13 | ||||
-rw-r--r-- | std/flags/example.ts | 5 | ||||
-rw-r--r-- | std/flags/mod.ts | 9 |
3 files changed, 8 insertions, 19 deletions
diff --git a/std/flags/README.md b/std/flags/README.md index e9764f913..0b7f7fa65 100644 --- a/std/flags/README.md +++ b/std/flags/README.md @@ -12,12 +12,12 @@ console.dir(parse(args)); ``` ``` -$ deno run example.ts -a beep -b boop +$ deno run https://deno.land/std/examples/flags.ts -a beep -b boop { _: [], a: 'beep', b: 'boop' } ``` ``` -$ deno run example.ts -x 3 -y 4 -n5 -abc --beep=boop foo bar baz +$ deno run https://deno.land/std/examples/flags.ts -x 3 -y 4 -n5 -abc --beep=boop foo bar baz { _: [ 'foo', 'bar', 'baz' ], x: 3, y: 4, @@ -56,16 +56,13 @@ options can be: the `--` and `parsedArgs['--']` with everything after the `--`. Here's an example: ```ts + // $ deno run example.ts -- a arg1 const { args } = Deno; import { parse } from "https://deno.land/std/flags/mod.ts"; - // options['--'] is now set to false console.dir(parse(args, { "--": false })); - // $ deno run example.ts -- a arg1 - // output: { _: [ "example.ts", "a", "arg1" ] } - // options['--'] is now set to true + // output: { _: [ "a", "arg1" ] } console.dir(parse(args, { "--": true })); - // $ deno run example.ts -- a arg1 - // output: { _: [ "example.ts" ], --: [ "a", "arg1" ] } + // output: { _: [], --: [ "a", "arg1" ] } ``` - `options.unknown` - a function which is invoked with a command line parameter not defined in the `options` configuration object. If the function returns diff --git a/std/flags/example.ts b/std/flags/example.ts deleted file mode 100644 index ad0317269..000000000 --- a/std/flags/example.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -const { args } = Deno; -import { parse } from "./mod.ts"; - -console.dir(parse(args)); diff --git a/std/flags/mod.ts b/std/flags/mod.ts index 0563dab61..e3680087d 100644 --- a/std/flags/mod.ts +++ b/std/flags/mod.ts @@ -14,16 +14,13 @@ export interface ArgParsingOptions { /** When `true`, populate the result `_` with everything before the `--` and * the result `['--']` with everything after the `--`. Here's an example: * + * // $ deno run example.ts -- a arg1 * const { args } = Deno; * import { parse } from "https://deno.land/std/flags/mod.ts"; - * // options['--'] is now set to false * console.dir(parse(args, { "--": false })); - * // $ deno run example.ts -- a arg1 - * // output: { _: [ "example.ts", "a", "arg1" ] } - * // options['--'] is now set to true + * // output: { _: [ "a", "arg1" ] } * console.dir(parse(args, { "--": true })); - * // $ deno run example.ts -- a arg1 - * // output: { _: [ "example.ts" ], --: [ "a", "arg1" ] } + * // output: { _: [], --: [ "a", "arg1" ] } * * Defaults to `false`. */ |