-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (33 loc) · 846 Bytes
/
index.js
File metadata and controls
41 lines (33 loc) · 846 Bytes
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
#!/usr/bin/env node
const figlet = require('figlet');
const chalk = require('chalk');
const args = process.argv.slice(2);
const library = require('./src');
const init = async (args) => {
if ( args.length < 1 ) {
console.warn("invalid number of arguments provided..");
return;
}
let func = camelCase(args[0]);
if ( !library.hasOwnProperty(func) ) {
throw Error("Invalid function provided");
}
await library[func](...args.slice(1));
};
init(args)
.then(_ => {
console.log(
chalk.red(
figlet.textSync('Your keys, your money!', {
font: 'Ghost',
horizontalLayout: 'full'
})
)
);
})
.catch(err => console.warn(err));
function camelCase(input) {
return input.toLowerCase().replace(/-(.)/g, function(match, group1) {
return group1.toUpperCase();
});
}