This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
35 lines (33 loc) · 1.23 KB
/
index.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
import yargs from "yargs";
import chalk from "chalk";
import { processFile } from "./ProcessFile";
// tslint:disable-next-line: no-unused-expression
yargs
.command(
"* [file] [output]",
"de/compress given file",
builder => builder
.positional("file", { describe: "file to compress/decompress", type: "string", alias: "in" })
.positional("output", { describe: "file output, [input].lzw if not specified", type: "string", alias: "out" })
.demandOption("file")
.option("compress", { alias: "C", boolean: true })
.option("decompress", { alias: "D", boolean: true })
.conflicts("compress", "decompress")
.option("force", {
alias: "f", boolean: true,
describe: "forces overvriting output file when already existrs",
})
,
(async args => {
const operation = (args.compress && "C") || (args.decompress && "D") || undefined;
const forceOverwrite = args.force || false;
try {
const t0 = Date.now();
await processFile(args.file as string, args.output as string, operation, forceOverwrite);
console.info(chalk.green(`Done ! ${Date.now() - t0} ms`));
} catch (e) {
console.error(chalk.red(e.message));
}
}))
.argv
;