Skip to content

Commit f409632

Browse files
committed
readME!
1 parent cd41a30 commit f409632

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,48 @@
33
A pretty basic argument parser
44

55
https://jsr.io/@nin0/cmd
6+
7+
## Usage
8+
9+
Use the `parseArgs` function:
10+
11+
```js
12+
parseArgs(`!ban @nin0.dev --reason "annoying" -p`, {
13+
prefix: "!",
14+
positionalArgumentName: "user"
15+
});
16+
```
17+
18+
and you'll get:
19+
20+
```js
21+
{
22+
commandName: "ban",
23+
args: {
24+
p: "true",
25+
reason: "annoying",
26+
user: "@nin0.dev"
27+
}
28+
}
29+
```
30+
31+
## Supported argument forms
32+
33+
```
34+
Flags
35+
-p
36+
--permanent
37+
38+
Short form, strings
39+
-r "annoying"
40+
-r 'annoying'
41+
-r annoying (can be used with one word values)
42+
43+
Long form, strings
44+
--reason "annoying"
45+
--reason="annoying"
46+
--reason 'annoying'
47+
--reason='annoying'
48+
--reason annoying (can be used with one word values)
49+
--reason=annoying (can be used with one word values)
50+
```

src/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parseArgs } from "./main.ts";
22

3-
const testString = `!ban --fakeUser nin0`;
3+
const testString = `!ban @nin0.dev --reason "annoying" -p`;
44

55
console.log(
66
parseArgs(testString, {

0 commit comments

Comments
 (0)