-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.ts
32 lines (26 loc) · 1.02 KB
/
cli.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
/**
* Copyright (c) Crew Dev.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { fetchFromArgs, fetchFromRequestFile } from "./utils/request/fetch.ts";
import { runCommandFilePath } from "./info.ts";
import { getRequest } from "./utils/request/getRequest.ts";
import versionCommand from "./commands/version.ts";
import helpCommand from "./commands/help.ts";
import Output from "./utils/output/output.ts";
import parse from "./utils/args/parser.ts";
const args = parse(Deno.args);
if (args) {
const { type, data } = args;
if (type === "flag") {
console.log(data.flags.version ? versionCommand : helpCommand);
}
if (type === "command" && data.command === "run") {
const alias = data.body;
const request = await getRequest(alias, runCommandFilePath);
Output.response(await fetchFromRequestFile(request.url, request));
}
if (type === "request") Output.response(await fetchFromArgs(data));
} else console.log(helpCommand);