Skip to content

Commit 93b490c

Browse files
committed
chore: update readme
1 parent f9a3e39 commit 93b490c

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

.changeset/bright-nails-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ultraflag": patch
3+
---
4+
5+
Update README

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
# `ultraflag`
22

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.
44

55
### Features
66

77
- It's very small.
88
- 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+
```

src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
BooleanType,
77
StringType,
88
Collectable,
9-
Negatable,
109
Aliases,
1110
} from "./types.js";
1211
export { ParseOptions, Args } from "./types.js";
@@ -69,14 +68,13 @@ export function parse<
6968
TBooleans,
7069
TStrings,
7170
TCollectable,
72-
TNegatable,
71+
undefined,
7372
TDefaults,
7473
TAliases
7574
>,
7675
TBooleans extends BooleanType = undefined,
7776
TStrings extends StringType = undefined,
7877
TCollectable extends Collectable = undefined,
79-
TNegatable extends Negatable = undefined,
8078
TDefaults extends Record<string, unknown> | undefined = undefined,
8179
TAliases extends Aliases<TAliasArgNames, TAliasNames> | undefined = undefined,
8280
TAliasArgNames extends string = string,

src/types.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,25 +211,16 @@ type ValueOf<TValue> = TValue[keyof TValue];
211211
/** The value returned from `parse`. */
212212
export type Args<
213213
// 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>
216215
> = Id<
217216
& TArgs
218217
& {
219218
/** Contains all the arguments that didn't have an option associated with
220219
* them. */
221220
_: Array<string | number | boolean>;
222221
}
223-
& (boolean extends TDoubleDash ? DoubleDash
224-
: true extends TDoubleDash ? Required<DoubleDash>
225-
: Record<never, never>)
226222
>;
227223

228-
type DoubleDash = {
229-
/** Contains all the arguments that appear after the double dash: "--". */
230-
"--"?: Array<string>;
231-
};
232-
233224
/** The options for the `parse` call. */
234225
export interface ParseOptions<
235226
TBooleans extends BooleanType = BooleanType,

0 commit comments

Comments
 (0)