dthree / vorpal

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

vorpal.parse() not working #174

Open tocttou opened 8 years ago

tocttou commented 8 years ago

version: 1.11.4 node version: 6.3.1

I am following the docs but vorpal.parse() seems to be broken. Can you please tell me what is wrong here? Thanks.

index.js

const vorpal = require('vorpal');

const vcl = vorpal();
const chalk = vorpal().chalk;

vcl
  .delimiter(chalk.cyan('choreo$'))
  .show()
  .parse(process.argv);

vcl
  .command('duck', 'Outputs "rabbit"')
  .action(function(args, callback) {
    console.log('quack');
  });

Terminal output:

➜  choreograph-cli git:(master) ✗ node src/index.js duck  
choreo$ 

  Invalid Command. Showing Help:

  Commands:

    help [command...]  Provides help for a given command.
    exit               Exits application.

choreo$ 
chrisui commented 8 years ago

@tocttou I think you may have to process the args before passing into parse first. Ie. to get rid of [node, src/index.js]

I've been doing the following:

const parsedArgs = vorpal.parse(process.argv, {use: 'minimist'});
vorpal.parse(parsedArgs._)

Before I was running as you were, just passing raw argv and saw the same error. However now I am currently seeing my program execute without actually running any commands although I see no error. :(

chrisui commented 8 years ago

Note I've documented my issue more thoroughly over in https://github.com/dthree/vorpal/issues/171