1.2.1 • Published 8 years ago

fredrick v1.2.1

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

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));
1.2.1

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago