dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Arguments with pipe character are not parsed. #140

Closed scotthovestadt closed 8 years ago

scotthovestadt commented 8 years ago

Failing test:

it('should parse pipe character in command argument', function (done) {
  exec('say "(vorpal|Vorpal)", done', done, function () {
    stdout().should.equal('(vorpal|Vorpal)');
    done();
  });
});
scotthovestadt commented 8 years ago

Looks like the issue is the code that actually matches a command:

matchCommand: function (cmd, cmds) {
  const parts = String(cmd).trim().split('|')[0].split(' ');

Need to be smarter about not splitting on pipe characters when they are quotes.

scotthovestadt commented 8 years ago

Looks like multiple places are naive about pipes. In util.js:

function parsePipes() {
  const newPipes = String(command).trim().split('|').map((itm) => String(itm).trim());
  command = newPipes.shift();
  pipes = pipes.concat(newPipes);
}