From 13e48d46bfdd4526d9572362611636031e2d7188 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 2 Jul 2016 14:05:38 -0600 Subject: [PATCH] Clean up usage, add info about config --- oputil.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/oputil.js b/oputil.js index d1af5e9a..3a04c5fb 100755 --- a/oputil.js +++ b/oputil.js @@ -27,30 +27,38 @@ const ExitCodes = { BAD_ARGS : -3, } +const USAGE_HELP = { + General : +`usage: optutil.js [--version] [--help] + [] + +global args: + --config PATH : specify config path (${getDefaultConfigPath()}) + +commands: + user : user utilities + config : config file management + +`, + User : +`usage: optutil.js user --user USERNAME + +valid args: + --user USERNAME : specify username + -- password PASS : specify password (to reset) +`, +} + function printUsage(command) { - var usage; + let usage; switch(command) { case '' : - usage = - 'usage: oputil.js [--version] [--help]\n' + - ' []' + - '\n\n' + - 'global args:\n' + - ' --config PATH : specify config path' + - '\n\n' + - 'commands:\n' + - ' user : User utilities' + - '\n'; + usage = USAGE_HELP.General; break; case 'user' : - usage = - 'usage: optutil.js user --user USERNAME \n' + - '\n' + - 'valid args:\n' + - ' --user USERNAME : specify username\n' + - ' --password PASS : reset password to PASS'; + usage = USAGE_HELP.User; break; } @@ -142,7 +150,7 @@ const QUESTIONS = { { name : 'configPath', message : 'Configuration path:', - default : getDefaultConfigPath(), + default : argv.config ? argv.config : getDefaultConfigPath(), when : answers => answers.createNewConfig }, ],