1.0.22 • Published 7 years ago

crocess v1.0.22

Weekly downloads
3
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.6.18

8 years ago

0.6.17

8 years ago

0.6.16

8 years ago

0.6.15

8 years ago

0.6.14

8 years ago

0.6.13

8 years ago

0.6.12

8 years ago

0.6.11

8 years ago

0.6.10

8 years ago

0.6.9

8 years ago

0.6.8

8 years ago

0.6.7

8 years ago

0.6.6

8 years ago

0.6.5

8 years ago

0.6.4

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.33

8 years ago

0.4.32

8 years ago

0.4.31

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.13

8 years ago

0.3.12

8 years ago

0.1.0

8 years ago