-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_management.ts
41 lines (38 loc) · 1016 Bytes
/
request_management.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
import { CliBuilder, Command } from "commandzen";
const cli = CliBuilder.create({
name: "hreq",
description: "HTTP request CLI tool",
});
cli.addCommand(
Command.create({
name: "request",
description: "Send an HTTP request",
aliases: ["req"],
})
.addOption({
flag: "-u, --url <url>",
description: "The URL to send the request to",
})
.addOption({
flag: "-m, --method <method>",
description: "The HTTP method to use (GET, POST, PUT, DELETE, etc.)",
})
.addOption({
flag: "-H, --header <header>",
description: "Add an HTTP header (can be used multiple times)",
multiple: true,
})
.addOption({
flag: "-d, --data <data>",
description: "The data to send in the request body",
})
.registerAction<{
url: string;
method: string;
header: string[];
data?: string;
}>(async ({ url, method, header, data }) => {
// Implement the HTTP request operation here.
})
);
cli.parse();