-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
62 lines (58 loc) · 1.62 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
import meow from "meow";
import * as R from "rambda";
import { mani } from "./source";
const cli = meow(
`
Usage
$ console-fun <input>
Options
--topic, -t Topic, (e.g. game, print)
--item, -i Item to be used in context of topic (e.g. hacker-types, read-file, colored-stars-watcher)
--subject Subject to be used in context of some items (e.g. filename for read-file item)
--color Color to be used in context of some items
--dimension Matrix size for grid-like games
--delay Delay value to be used for example when reading file line-by-line
Examples
$ console-fun --topic game --item stars-watcher
$ console-fun --topic game --item colored-stars-watcher
$ console-fun --topic print --item hacker-types
$ console-fun --topic print --item char-by-char
$ console-fun --topic print --item read-file --subject tmp/bar.txt
`,
{
importMeta: import.meta, // This is required
flags: {
topic: {
type: "string",
shortFlag: "t",
},
item: {
type: "string",
shortFlag: "k",
},
subject: {
type: "string",
shortFlag: "s",
},
color: {
type: "string",
shortFlag: "c",
},
dimension: {
type: "string",
shortFlag: "d",
},
delay: {
type: "string",
shortFlag: "e",
},
colored: {
type: "boolean",
},
},
},
);
const toPick = ["subject", "color", "dimension", "delay", "colored"];
const options = R.reject(R.isNil, R.pick(toPick, cli.flags));
mani(cli.flags.topic, cli.flags.item, options);