1.0.22 • Published 9 years ago

crocess v1.0.22

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Crocess

npm Travis license

Make your command-line programs be easily called by externals.

Links

Requirements

  • Node.js >= 6.0.0

Installation

$ npm install crocess

Quick Start

Learn more about Application

Create an application instance and return data to console:
var Application = require('crocess').Application;

new Application().boot(function () {
    console.log('Hello world!');

    return { 'foo': 'bar' };
});

You will see this on console:

Hello world!
>>>>>BEGIN_RESULT>>>>>{"foo":"bar"}
You can also return a Promise.
new Application().boot(function () {
    return Promise.resolve({"foo":"bar"});
});

// or using 'async/await'.

new Application().boot(async function () {
    return await Promise.resolve({"foo":"bar"});
});

// => >>>>>BEGIN_RESULT>>>>>{"foo":"bar"}

Get Parameters

You can pass the parameters as a json formatted string with the --parameters argument.

node example.js --parameters='{"name":"World"}'

Example:

new Application().boot(function () {
    return 'Hello ' + this.parameters.name;
});

// => >>>>>BEGIN_RESULT>>>>>Hello World

The parameters property will be empty when the --parameters argument not given.

Using Suite

Learn more about Suites

An example suite class:

var Application = require('crocess').Application;
var BaseSuite = require('crocess').Suite;

class Example extends BaseSuite
{
    /**
     * Start handle the suite.
     */
    handle() {
        console.log('Hello suite!');

        return 'foobar';
    }
}

Now, boot the suite:

new Application().boot(new Example);

You will see this on console:

Hello suite!
>>>>>BEGIN_RESULT>>>>>foobar

Another way to boot suites:

new Application().boot(function () {
    return new Example().boot(this);
});

If you need to passing something to the suite, a very straightforward way is override the constructor:

class Example extends BaseSuite
{
    constructor(foo) {
        super();

        this.foo = foo;
    }
}
1.0.22

9 years ago

1.0.21

9 years ago

1.0.20

9 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.6.18

10 years ago

0.6.17

10 years ago

0.6.16

10 years ago

0.6.15

10 years ago

0.6.14

10 years ago

0.6.13

10 years ago

0.6.12

10 years ago

0.6.11

10 years ago

0.6.10

10 years ago

0.6.9

10 years ago

0.6.8

10 years ago

0.6.7

10 years ago

0.6.6

10 years ago

0.6.5

10 years ago

0.6.4

10 years ago

0.6.3

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.33

10 years ago

0.4.32

10 years ago

0.4.31

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.13

10 years ago

0.3.12

10 years ago

0.1.0

10 years ago