-
Notifications
You must be signed in to change notification settings - Fork 0
/
pickit.ts
95 lines (89 loc) · 2.07 KB
/
pickit.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// command line interface for pickit
// semantics:
// - pickit [source] [outputDir] [glob1] [glob2]...
// - pickit ./config.ts (default: ./.pickit.ts)
import { cleanFetchCache, write } from "./mod.ts";
if (Deno.args.length == 1) {
if (Deno.args[0] == "clean") {
await cleanFetchCache();
} else if (Deno.args[0] == "help") {
printHelp();
} else {
const config = await import(Deno.args[0]);
await write(config.default);
}
} else if (Deno.args.length >= 3) {
const [source, output, ...pick] = Deno.args;
await write([{ source, output, pick }]);
} else {
printHelp();
}
function printHelp() {
console.log(
`
%cPickIt
`,
"font-size: 1.5em; font-weight: bold",
);
console.log(
`
This utility helps you to extract files from tarballs and github repos using glob syntax or regular expressions.
You can use either a config file or command line arguments.
pickit %cclean - cleans the cache of fetched files.
%cpickit %chelp - prints this help message.
`,
"color: #ccb;",
"",
"color: #ccb;",
);
console.log(
`
%cUsage:
`,
"font-size: 1.5em; font-weight: bold",
);
console.log(
`
pickit %c[source] [outputDir] [glob1] [glob2]...
%cpickit %c./config.ts
`,
"color: #ccb;",
"",
"color: #ccb;",
);
console.log(
`
%cExample:
`,
"font-size: 1.5em; font-weight: bold",
);
console.log(
`
%cpickit nesterow/pickit@v0.0.1 scripts *.d.ts **/tests/*.ts
`,
"color: #aab;",
);
console.log(
`
%cConfiguring (ts):
`,
"font-size: 1.5em; font-weight: bold",
);
console.log(
`%c
import type { PickConfig } from "https://deno.land/x/pickit/mod.d.ts";
export default [
{
source: "username/repo@version",
output: "./outputDir",
pick: [
/^.*\/base\/.*\.css$/,
"/src/index.js",
"/src/**/*.yaml"
],
},
] as PickConfig;
`,
"color: #aab;",
);
}