-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
executable file
·70 lines (60 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
'use strict';
// require
const cli = require('cli').enable('version');
const shell = require('shelljs');
const prompt = require('prompt');
const fs = require('fs');
const scp = require('scp');
// scripts require
const setup = require('./scripts/setup');
const utils = require('./scripts/utils');
// app details
cli.setApp('mura', '0.0.1');
/**
* An object of options to be parsed by cli.
* @type {Object}
*/
const options = {
file: ['f', 'A file to process', 'file', 'temp.log'],
time: ['t', 'An access time', 'time', false],
work: [false, 'What kind of work to do', 'string', 'sleep'],
env : ['e', 'Environment, Local/Staging/Production', 'string', 'local']
};
/**
* An array of commands to be parsed by cli.
* @type {Array}
*/
const commands = [
'init',
'gitTest', 'configTest'
];
/**
* Takes const options and const commands, then parses them.
* @param {Object} options a list of options available to the terminal.
* @param {Array} commands an array of commands available to the terminal.
* @return {null}
*/
cli.parse(options, commands);
// friendly message
console.log('MURA CLI'.bold.green + ` Version ${cli.version}`.bold.blue + ' Unofficial'.bold.yellow);
/****************************************
* Private FUNCTIONS AND COMMANDS BELOW *
*****************************************/
if (cli.command == 'init') {
cli.info(`Processing Command ${cli.command}`);
setup.init();
cli.ok(`Command ${cli.command} Complete!`);
};
/**
* A simple test that prompts the user for a username and a password,
* then outputs the users input to the terminal.
* @param {Array} a simple array of strings to be used
* @return {null}
*/
if (cli.command == 'promptTest') {
prompt.get(['username', 'password'], function(err, res) {
console.log(res.username);
console.log(res.password);
});
}