vorpal icon indicating copy to clipboard operation
vorpal copied to clipboard

subcommands in mode

Open NonPolynomial opened this issue 6 years ago • 3 comments

is there a recommended way to do subcommands for modes?

NonPolynomial avatar Oct 24 '17 15:10 NonPolynomial

maybe include an example of what you want to do?

ORESoftware avatar Nov 06 '17 01:11 ORESoftware

is this similar to your issue? https://github.com/dthree/vorpal/issues/289

ORESoftware avatar Nov 06 '17 07:11 ORESoftware

@NonPolynomial did you find a good pattern or did you give up?

it would be awesome to have an example for this, like the sub-commands in commanderjs examples

I've looked at the code of cash to see a working example

config.commands.forEach(cmd => {
  try {
    const mod = require(`../lib/commands/${cmd}`)
    program.use(mod);
  } catch (e) {
    program.log(`Error loading command ${cmd}: `, e);
  }
})

but on the sub-commands files I do this:

module.exports = (program, options) => {
  program
    .command('foo list')
    .action((args, callback) => {
      callback();
    });

  program
    .command('foo scan')
    .action((args, callback) => {
      callback();
    });
}

but.. I've understood from this issue that the mode needs to be refactored in order to show the sub-commands as a stand-alone cli.

I don't know if it can help but I've almost archived what I wanted.

b4dnewz avatar Feb 13 '18 00:02 b4dnewz