vadimdemedes / ronin

Toolkit for killer CLI applications
http://vdemedes.github.io/ronin
MIT License
299 stars 15 forks source link

Command aliases #28

Open mappum opened 8 years ago

mappum commented 8 years ago

Ronin supports aliases for options, but not for commands. This would be a nice feature, since it can save a lot of typing for power users (e.g. npm i vs npm install). The convention used for options could be used (alias: 'foo' and aliases: [ 'foo', 'bar' ]).

vadimdemedes commented 8 years ago

Good suggestion ;)

daviddias commented 8 years ago

:+1: :D

jprichardson commented 8 years ago

:+1:

devjack commented 8 years ago

Looked into implementing this tonight. From my understanding a program stores commands as a name => path.js set and then lazy loads the command from the path if it matches. The lazy loading prevents reading in any command props like command.aliases: ['myalias', 'other alias'] etc.

To keep lazy loading of commands it would either require: a) command aliases to be defined at a program level e.g.:

var ronin = require('ronin');
var program = ronin({
  path: __dirname,
  aliases: {'alias': 'command'},
  desc: 'Sample for implementing command aliases'
});
program.run();

b) default to loading all commands and then unwinding aliases if the lazy loading technique fails.

vadimdemedes commented 8 years ago

Don't worry guys, I will get to it ASAP. Ronin needs a complete rewrite anyway.