-
Notifications
You must be signed in to change notification settings - Fork 4
/
error.ts
42 lines (41 loc) · 1.2 KB
/
error.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
import { bold, cyan, red } from "./deps.ts";
export const displayHelpAndQuit = (error?: string): void => {
if (!error) {
} else if (error === "INVALID_KEY") {
console.log(
bold(red(`Error: Invalid API key. Use --config flag to set key`)),
);
} else console.log(bold(red(`Error: ${error}`)));
console.log(`Usage: news-cli [filters]\n`);
console.log(`Optional flags:`);
console.log(` ${bold("-h, --help")}\t\t Shows this help message and exits`);
console.log(
` ${
bold(
"-l, --latest",
)
}\t\t If the flag is set, then news will be returned only from latest headlines`,
);
console.log(
` ${bold("-q, --query")}\t\t Find news related to a specific keyword`,
);
console.log(
` ${
bold(
"-c, --category",
)
}\t Find news in a valid category (only applicable if used with -l, --latest).\n\t\t\t The valid categories are: business, entertainment, general, health, science, sports, technology`,
);
console.log(
` ${
bold(
"--config <API_KEY>",
)
}\t Set API key for news API. The key can be received from ${
cyan(
`https://newsapi.org/register`,
)
}`,
);
Deno.exit();
};