toolsmith

0.5.2 • Public • Published

Toolsmith Toolsmith

npm version pipeline status coverage status standard-js conventional commits

Yet another CLI tool framework.

Installation

npm install toolsmith

Basic Example

#!/usr/bin/env node
require('toolsmith')()
  .summary('An example command.')
  .option({
    long: 'foo',
    desc: 'Enable foo.'
  })
  .parameter({
    name: 'bar',
    desc: 'Specify one or more values for bar.',
    variadic: true
  })
  .handler((ctx) => {
    if (ctx.opts.foo) {
      console.log('foo is enabled')
    }
    console.log('bar is ' + ctx.args.bar.join(', '))
  })
  .parse()
$ ./example.js --help
Usage: example.js [OPTIONS...] <bar...>
Summary:
  An example command.
Parameters:
  bar  Specify one or more values for bar.
Options:
  -h,--help  You are here.
     --foo   Enable foo.

$ ./example.js --foo some example values
foo is enabled
bar is some, example, values

Documentation

API documentation can be found here.

Package Sidebar

Install

npm i toolsmith

Weekly Downloads

0

Version

0.5.2

License

Apache-2.0

Unpacked Size

35.8 kB

Total Files

10

Last publish

Collaborators

  • cptpackrat