From 65c6421b4238551af2014673a283ea960ee0b371 Mon Sep 17 00:00:00 2001 From: Scott Doxey Date: Wed, 30 Oct 2019 18:19:33 -0400 Subject: [PATCH 1/2] Added chalk and meow for managing cli input and flags. --- bin/index.js | 26 +++++++++++++++++++++----- package.json | 4 ++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/bin/index.js b/bin/index.js index dd79fc7..d63e1b3 100755 --- a/bin/index.js +++ b/bin/index.js @@ -2,16 +2,32 @@ const os = require('os'); +const chalk = require('chalk'); +const meow = require('meow'); + const getUnityUrls = require('../lib/get-unity-urls'); +const cli = meow( + ` + Usage + $ get-unity [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(); - -getUnityUrls(requestedVersion).then(urls => +getUnityUrls(cli.input[0]).then(urls => process.stdout.write(`${urls[osKeyMap[os.type()]]}`)); diff --git a/package.json b/package.json index 115d5ac..cda3053 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,10 @@ "node": ">=12.0" }, "license": "MIT", + "dependencies": { + "chalk": "2.4.2", + "meow": "5.0.0" + }, "devDependencies": { "@neogeek/eslint-config-standards": "github:neogeek/eslint-config-standards", "babel-eslint": "10.0.3", From 778a55c17379ebdf51a2471c64c8440a7fb9907c Mon Sep 17 00:00:00 2001 From: Scott Doxey Date: Wed, 30 Oct 2019 18:24:25 -0400 Subject: [PATCH 2/2] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15a06a7..92560b1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "license": "MIT", "dependencies": { "chalk": "2.4.2", - "meow": "5.0.0" + "meow": "5.0.0", "update-notifier": "3.0.1" }, "devDependencies": {