Skip to content

Commit

Permalink
Added chalk and meow for managing cli input and flags. (#8)
Browse files Browse the repository at this point in the history
* Added chalk and meow for managing cli input and flags.

* Update package.json
  • Loading branch information
neogeek authored Oct 30, 2019
1 parent daee768 commit 71939cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 21 additions & 5 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,38 @@

const os = require('os');

const chalk = require('chalk');
const meow = require('meow');

const updateNotifier = require('update-notifier');

const pkg = require('../package.json');

const getUnityUrls = require('../lib/get-unity-urls');

const cli = meow(
`
Usage
$ get-unity <version> [options]
Options
${chalk.yellow('--help, -h')} Display this help message.
${chalk.yellow('--version, -v')} Display the current installed version.
`,
{
'flags': {
'autoHelp': true,
'autoVersion': true
}
}
);

const osKeyMap = {
'Darwin': 'mac',
'Windows_NT': 'win64'
};

const PROCESS_CMD_LINE_ARGS_LENGTH = 2;

const requestedVersion = process.argv.slice(PROCESS_CMD_LINE_ARGS_LENGTH).pop();

updateNotifier({pkg}).notify();

getUnityUrls(requestedVersion).then(urls =>
getUnityUrls(cli.input[0]).then(urls =>
process.stdout.write(`${urls[osKeyMap[os.type()]]}`));
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"license": "MIT",
"dependencies": {
"chalk": "2.4.2",
"meow": "5.0.0",
"update-notifier": "3.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit 71939cd

Please sign in to comment.