-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (51 loc) · 1.2 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
#!/usr/bin/env node
const chalk = require("chalk");
const boxen = require("boxen");
const yargs = require("yargs");
const fs = require("fs");
/*function parse_arg_one(data) {
let filename = "";
switch(data) {
case "help":
// code block
break;
case "version":
// code block
Console.log("1.0.0");
break;
default:
// code block
filename = data;
return filename;
}
}*/
var argv = require('yargs')
.options({
'file': {
alias: 'f',
describe: 'the path to the package.json',
demandOption: true
},
'about': {
alias: 'a',
describe: 'About this application',
demandOption: false
}
})
.help()
.argv
var filename = argv.file;
var info = JSON.parse(fs.readFileSync(filename))
var creator = info.author
var version = info.version
var name = info.name
var description = info.description
var license = info.license
var lineone = name + " v" + version;
var linetwo = "Under the " + license + " License"
var linethree = "Created by " + creator;
var linefour = "Description: " + description;
console.log(chalk.green(lineone));
console.log(chalk.red(linetwo));
console.log(chalk.green(linethree));
console.log(chalk.blue(linefour));