File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33A pretty basic argument parser
44
55https://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+ ```
Original file line number Diff line number Diff line change 11import { parseArgs } from "./main.ts" ;
22
3- const testString = `!ban --fakeUser nin0 ` ;
3+ const testString = `!ban @nin0.dev --reason "annoying" -p ` ;
44
55console . log (
66 parseArgs ( testString , {
You can’t perform that action at this time.
0 commit comments