[READ-ONLY] Mirror of https://github.com/bombshell-dev/args. <1kB CLI flag parser
args args-parser cli command-line command-line-parser node
5

Configure Feed

Select the types of activity you want to include in your feed.

chore: update readme

Nate Moore (Feb 4, 2023, 2:25 PM -0600) 93b490c8 f9a3e39d

+35 -15
+5
.changeset/bright-nails-march.md
··· 1 + --- 2 + "ultraflag": patch 3 + --- 4 + 5 + Update README
+28 -2
README.md
··· 1 1 # `ultraflag` 2 2 3 - A <1kB library for parsing CLI flags. 3 + A <1kB library for parsing CLI flags. Inspired by Deno's `std` [`flags`](https://github.com/denoland/deno_std/blob/main/flags/mod.ts) module. 4 4 5 5 ### Features 6 6 7 7 - It's very small. 8 8 - It's very fast. 9 - - I need to write docs. 9 + 10 + ### Usage 11 + 12 + Basic usage does not require any configuration. 13 + 14 + ```js 15 + import { parse } from "ultraflag"; 16 + 17 + // my-cli build --bundle -rf --a value --b=value --c 1 18 + const argv = process.argv.slice(2); 19 + const args = parse(argv); 20 + 21 + console.log(args); 22 + // { _: ['build'], bundle: true, r: true, f: true, a: "value", b: "value", c: 1 } 23 + ``` 24 + 25 + Parsing can be configured to ensure values are handled in a certain format. 26 + 27 + ```js 28 + const args = parse(argv, { 29 + default: { a: 1, b: 2, c: "value" }, 30 + alias: { h: "help" }, 31 + boolean: ["foo", "bar"], 32 + string: ["baz", "qux"], 33 + array: ["input"], 34 + }); 35 + ```
+1 -3
src/index.ts
··· 6 6 BooleanType, 7 7 StringType, 8 8 Collectable, 9 - Negatable, 10 9 Aliases, 11 10 } from "./types.js"; 12 11 export { ParseOptions, Args } from "./types.js"; ··· 69 68 TBooleans, 70 69 TStrings, 71 70 TCollectable, 72 - TNegatable, 71 + undefined, 73 72 TDefaults, 74 73 TAliases 75 74 >, 76 75 TBooleans extends BooleanType = undefined, 77 76 TStrings extends StringType = undefined, 78 77 TCollectable extends Collectable = undefined, 79 - TNegatable extends Negatable = undefined, 80 78 TDefaults extends Record<string, unknown> | undefined = undefined, 81 79 TAliases extends Aliases<TAliasArgNames, TAliasNames> | undefined = undefined, 82 80 TAliasArgNames extends string = string,
+1 -10
src/types.ts
··· 211 211 /** The value returned from `parse`. */ 212 212 export type Args< 213 213 // deno-lint-ignore no-explicit-any 214 - TArgs extends Record<string, unknown> = Record<string, any>, 215 - TDoubleDash extends boolean | undefined = undefined, 214 + TArgs extends Record<string, unknown> = Record<string, any> 216 215 > = Id< 217 216 & TArgs 218 217 & { ··· 220 219 * them. */ 221 220 _: Array<string | number | boolean>; 222 221 } 223 - & (boolean extends TDoubleDash ? DoubleDash 224 - : true extends TDoubleDash ? Required<DoubleDash> 225 - : Record<never, never>) 226 222 >; 227 - 228 - type DoubleDash = { 229 - /** Contains all the arguments that appear after the double dash: "--". */ 230 - "--"?: Array<string>; 231 - }; 232 223 233 224 /** The options for the `parse` call. */ 234 225 export interface ParseOptions<