diff --git a/src/command-line/index.js b/src/command-line/index.js index e9e81f13..cffc330e 100644 --- a/src/command-line/index.js +++ b/src/command-line/index.js @@ -16,12 +16,6 @@ program "override entries of the configuration file, must be specified for each entry that needs to be overriden", Utils.parseConfigOptions ) - .on("command:*", () => { - log.error( - `Unknown command. See ${colors.bold("--help")} for a list of available commands.` - ); - process.exit(1); - }) .on("--help", Utils.extraHelp); // Parse options from `argv` returning `argv` void of these options. @@ -58,13 +52,9 @@ require("./outdated"); // a version of `argv` that does not contain options already parsed by // `parseOptions` above. // This is done by giving it the updated `argv` that `parseOptions` returned, -// except it returns an object with `args`/`unknown`, so we need to concat them. +// except it returns an object with `operands`/`unknown`, so we need to concat them. // See https://github.com/tj/commander.js/blob/fefda77f463292/index.js#L686-L763 -program.parse(argvWithoutOptions.args.concat(argvWithoutOptions.unknown)); - -if (program.rawArgs.length < 3) { - program.help(); -} +program.parse(argvWithoutOptions.operands.concat(argvWithoutOptions.unknown)); function createPackagesFolder() { const packagesPath = Helper.getPackagesPath(); diff --git a/src/command-line/upgrade.js b/src/command-line/upgrade.js index e3b60524..c99538a4 100644 --- a/src/command-line/upgrade.js +++ b/src/command-line/upgrade.js @@ -8,7 +8,7 @@ const Utils = require("./utils"); program .command("upgrade [packages...]") - .description("Upgrade installed themes and packages to their latest versions.") + .description("Upgrade installed themes and packages to their latest versions") .on("--help", Utils.extraHelp) .action(function(packages) { const fs = require("fs"); diff --git a/src/command-line/users/edit.js b/src/command-line/users/edit.js index b9b084da..6e659e84 100644 --- a/src/command-line/users/edit.js +++ b/src/command-line/users/edit.js @@ -10,7 +10,7 @@ const Utils = require("../utils"); program .command("edit ") - .description(`Edit user file located at ${colors.green(Helper.getUserConfigPath(""))}.`) + .description(`Edit user file located at ${colors.green(Helper.getUserConfigPath(""))}`) .on("--help", Utils.extraHelp) .action(function(name) { if (!fs.existsSync(Helper.getUsersPath())) { diff --git a/src/command-line/utils.js b/src/command-line/utils.js index 3837a3a8..859d2991 100644 --- a/src/command-line/utils.js +++ b/src/command-line/utils.js @@ -13,12 +13,10 @@ class Utils { static extraHelp() { [ "", - "", - " Environment variable:", - "", - ` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green( + "Environment variable:", + ` THELOUNGE_HOME Path for all configuration files and folders. Defaults to ${colors.green( Helper.expandHome(Utils.defaultHome()) - )}.`, + )}`, "", ].forEach((e) => log.raw(e)); } diff --git a/test/src/command-line/utilsTest.js b/test/src/command-line/utilsTest.js index bd6b97ce..f0dc605a 100644 --- a/test/src/command-line/utilsTest.js +++ b/test/src/command-line/utilsTest.js @@ -19,10 +19,9 @@ describe("Utils", function() { Utils.extraHelp(); - // Starts with 2 empty lines + // Starts with 1 empty line expect(stdout[0]).to.equal("\n"); - expect(stdout[1]).to.equal("\n"); - expect(stdout[2]).to.not.equal("\n"); + expect(stdout[1]).to.not.equal("\n"); // Ends with 1 empty line expect(stdout[stdout.length - 2]).to.not.equal("\n");