-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·59 lines (53 loc) · 1.37 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
#!/usr/bin/env node
import meow from "meow";
import slugify from "@sindresorhus/slugify";
import cp from "copy-paste";
const cli = meow(
`
Usage
$ slugcopy <string>
Options
--separator=<string> Word separator [Default: -]
--no-lowercase Don’t make the slug lowercase [Default: true]
--no-decamelize Don’t convert camelCase to separate words [Default: true]
--preserve-leading-underscore If your string starts with an underscore, it will be preserved in the slugified string [Default: false]
--no-copy Don't copy the slug to the clipboard [Default: false]
Examples
$ slugcopy Déjà Vu!
deja-vu
$ slugcopy Like a Boss --no-lowercase --separator='_'
Like_a_Boss
`,
{
importMeta: import.meta,
flags: {
separator: {
type: "string",
},
lowercase: {
type: "boolean",
default: true,
},
decamelize: {
type: "boolean",
default: true,
},
preserveLeadingUnderscore: {
type: "boolean",
default: false,
},
copy: {
type: "boolean",
default: true,
},
},
}
);
const text = cli.input.join(" ");
const output = slugify(text, cli.flags);
console.log(output);
if (cli.flags.copy) {
cp.copy(output, function () {
console.log("Copied to clipboard");
});
}