fredrick

1.2.1 • Public • Published

Fredrick

Build Status

simple module for writing your spiffy command line tools

Example

'use strict';
 
const Fredrick = require('fredrick');
 
let fredrick = new Fredrick('fredrick');
 
fredrick.addExtension({
  name: 'test1',
  func: function() {}
});
 
fredrick.addExtension({
  name: 'test2',
  extensions: ['test1'],
  func: function() {
    this.test1();
  }
});
 
fredrick.addProperty({
  name: 'value1',
  value: function() {
    return 10;
  }
})
 
fredrick.addPlugin({
  command: 'test',
  usage: 'fredrick test [--prod] [--error]',
  description: 'a test command',
  extensions: ['test2'],
  properties: ['value1'],
  func(fredrick, args, options) {
    if (options.prod) {
      fredrick.write('PRODUCTION!');
    }
 
    if (options.error) {
      fredrick.error('MY BAD!');
    }
 
    fredrick.test2();
 
    fredrick.value1 === 10;
 
    fredrick.write('TESTING');
    fredrick.exit(0);
  },
  subcommands: {
    list(fredrick, args, options) {
      fredrick.write('LISTING');
      fredrick.exit(0);
    }
  }
});
 
fredrick.respond(process.argv.slice(2));

Readme

Keywords

none

Package Sidebar

Install

npm i fredrick

Weekly Downloads

4

Version

1.2.1

License

ISC

Last publish

Collaborators

  • bthesorceror