dthree / vorpal

Node's framework for interactive CLIs

Home Page:http://vorpal.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Default help command does not support commands that are not entirely lower case

opened this issue · comments

I am using your library in a custom project which does not adhere to usual UNIX standards when naming the commands. It uses commands akin to PowerShell commandlets as in Write-Output. I wanted to rename help to Get-Help with a custom hook (either using mock or manually overriding Module.prototype.load) which had some since Get-Help Write-Output would not print the expected help for the particular Write-Output command.

After reverting my rename it turns out with your default help Write-Output the output is still Invalid command. After looking through the code for far too long it turns out that this line the culprit:

var name = _.find(this.parent.commands, {_name: String(args.command).toLowerCase().trim()});

Your default help command is calling toLowerCase on the argument and then looking for a write-output command. However debugging yields that the name of the command is not altered when creating it and still being Write-Output.

In order to fix this it is only necessary to remove the linked call toLowerCase. Unfortunately there are still two occurences of it:

var delimiter = match._delimiter || String(item.command).toLowerCase() + ':';

command = (command) ? String(command).trim().toLowerCase() : undefined;

I haven't figured out what they are exactly doing and whether my first change will break something. Once I know more and was able to test the change I am considering to open a pull request to fix this.