-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (36 loc) · 1.42 KB
/
index.js
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
#!/usr/bin/env node
// Package Imports
import Details from './config/details.js';
import Commands from './commands/commands.js';
import { get_all_Commands } from './commands/command.json.js';
// Package Extraction
const
details = new Details().getDetails(),
cmd = new Commands(),
{ Color, program } = cmd,
all_commands = get_all_Commands(cmd);
//-----> Cli Implementation begins <-----//
// CLi Details
program
.name(details.Name)
.version(Color.yellow.bold(details.Version), '-v, --version', 'show current version')
.description(details.Description)
.helpOption('-h, --help', 'show help')
.addHelpText('beforeAll', Color.bold(`\n\t${Color.red(details.Name)} ${Color.green(details.Version)}\n\tDeveloped by: ${Color.blue(details.Author)}\n${Color.yellow.bold(details.Homepage)}\n`));
program
.configureOutput({
// Visibly override write routines as example!
writeErr: (str) => process.stdout.write(str),
// Output errors in red.
outputError: (str, write) => write((str.replace('error:', Color.red.bold('Error:')).replace('warn:', Color.yellow.bold('Warn:')).replace('info:', Color.blue.bold('Info:')))),
});
// Cli Commands
all_commands.forEach((cli_cmd) => {
program
.command(cli_cmd.command)
.description(cli_cmd.description)
.action(cli_cmd.action);
});
// Cli Parse
program.parse(process.argv);
//-----> Cli Implementation ends <-----//