dthree / vorpal

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

Support for name, version, banner, description and a default value #224

Closed milesj closed 7 years ago

milesj commented 7 years ago

Loving Vorpal, but one feature I miss is a default view. Something that is rendered when the script is called with no command, like node toolkit.js or just toolkit. As of right now, it outputs nothing and simply exits.

It would be nice if we could do something like the following.

vorpal
  .version('1.2.3')
  .name('Toolkit')
  .description('User interface components built on React.')
  .parse(process.argv);

And when ran, would output the following.


  Toolkit v1.2.3
  User interface components built on React.

  Usage: toolkit <command> [options]

  Commands:

    help [command...]  Provides help for a given command.
    exit               Exits application.
    build [options]    Transpile source files.

  Options:

    --version  Output the current application version.
    --verbose  Log more information.

We can even go crazier by supporting banners that prepend to the top.

vorpal.banner(`
 ______   ______   ______   __       __  __   __   ______
/\__  _\ /\  __ \ /\  __ \ /\ \     /\ \/ /_ /\ \ /\__  _\
\/_/\ \/ \ \ \/\ \\ \ \/\ \\ \ \____\ \  _  \\ \ \\/_/\ \/
   \ \_\  \ \_____\\ \_____\\ \_____\\ \_\ \_\\ \_\  \ \_\
    \/_/   \/_____/ \/_____/ \/_____/ \/_/\/_/ \/_/   \/_/
`);
milesj commented 7 years ago

Will tackle possible default action in another PR.