Commander.js: v7.0.0 coming soon

Created on 25 Oct 2020  路  11Comments  路  Source: tj/commander.js

Release Notes:

README: https://github.com/tj/commander.js/blob/release/7.x/Readme.md

You can try the prerelease with:

npm install commander@next

Open an issue or add a comment here for any problems you encounter.

Most helpful comment

Aiming to release this Friday or over the weekend.

All 11 comments

Nice work @shadowspawn to keep this repo going! 馃憤 馃檹

I'll do another prerelease soon to add #1387

Prerelease v7.0.0-1 has a couple of new features, and a number of minor improvements. Release notes:

Work underway to change the default behaviour so options are _not_ stored as properties on the command: #1409

1409 has landed in v7.0.0-2 and includes multiple breaking changes! See the Release Notes and let us know if there are issues or the release notes could be improved.

The latest code for upcoming Commander 7 is now on the develop branch. There will not be another prerelease to npm, but you can try the latest code by installing from GitHub:

npm install tj/commander.js#develop

The main changes from 7.0.0-2 are:

  • added support for positional options #1427
  • made the new error for excess positional options opt-in rather can on by default #1429

For changes see:

Hi @shadowspawn,

When you plan to make a release?

Aiming to release this Friday or over the weekend.

7.0.0 has been released. Thanks to all who have contributed.

Hi @shadowspawn,

I wrote basic help extensions for commander.js@7, maybe will be useful for someone:

x-commander

const program = require('x-commander');

program.configureHelp({
  labels: {
    usage: '>>> Usage:\n',
    description: '>>> Description:\n',
    arguments: '>>> Arguments:\n',
    options: '>>> Options:\n',
    commands: '>>> Commands:\n',
  },
  styles: {
    label: str => '\x1b[33m' + str + '\x1b[0m', // yellow
    term: str => '\x1b[32m' + str + '\x1b[0m', // green
    description: str => '\x1b[36m' + str + '\x1b[0m', // cyan
  },
  formatParams: {
    newLineUsage: true,
    baseIndentWidth: 2,
    itemIndentWidth: 4,
  },
  formatHelp(cmd, helper) {
    return ['', helper.renderHelpTemplate(cmd, helper), ''].join('\n');
  }
});

program
  .command('test <cmd> [env] [val]')
  .description('long description '.repeat(100), {
    cmd: 'cmd description '.repeat(50),
    env: 'env description '.repeat(50),
    val: 'val description '.repeat(50)
  })
  .action((cmd, env, options) => {});

program.parse(process.argv);

Nice. I like the styles especially.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oknoorap picture oknoorap  路  4Comments

mathiasbynens picture mathiasbynens  路  3Comments

aminch picture aminch  路  3Comments

mtrabelsi picture mtrabelsi  路  3Comments

san-templates picture san-templates  路  5Comments