From 3663e2497521cde202bb3229fd84902578776e46 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Thu, 10 Jun 2021 08:48:10 -0600 Subject: [PATCH] Issue #845 -- show options for each command --- src/js/sandbox/commands.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/js/sandbox/commands.js b/src/js/sandbox/commands.js index 24158874..3e04cf97 100644 --- a/src/js/sandbox/commands.js +++ b/src/js/sandbox/commands.js @@ -115,6 +115,20 @@ var instantCommands = [ }], [/^show +commands$/, function(bits) { var allCommands = getAllCommands(); + var allOptions = Commands.commands.getOptionMap(); + var commandToOptions = {}; + + Object.keys(allOptions).forEach(function(vcs) { + var vcsMap = allOptions[vcs]; + Object.keys(vcsMap).forEach(function(method) { + var options = vcsMap[method]; + if (options) { + commandToOptions[vcs + ' ' + method] = Object.keys(options).filter(option => option.length > 1); + } + }); + }); + + var lines = [ intl.str('show-all-commands'), '
' @@ -122,6 +136,9 @@ var instantCommands = [ Object.keys(allCommands) .forEach(function(command) { lines.push(command); + if (commandToOptions[command]) { + commandToOptions[command].forEach(option => lines.push('    ' + option)); + } }); throw new CommandResult({