You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

machine-as-script

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machine-as-script

Run a machine as a command-line script.

1.1.0
Source
npmnpm
Version published
Weekly downloads
59
9.26%
Maintainers
1
Weekly downloads
 
Created
Source

machine-as-script

Build a modified version of a machine that proxies its inputs from CLI arguments and/or -- opts.

$ npm install machine-as-script --save

Usage

#!/usr/bin/env node

var asScript = require('machine-as-script');
var MPMath = require('machinepack-math');

asScript(MPMath.add).exec({
  success: function (sum){
    console.log('Got result:', sum);
  }
});

Now you can run your machine as a script and provide inputs as CLI opts:

$ node ./add-numbers.js --a=4 --b=5
# Got result: 9

Note that the machine definition you provide here doesn't have to come from an already-published machinepack-- it can be required locally from your project, or declared inline.

Using serial CLI arguments

You can use the args input to accept serial CLI arguments:

asScript({
  machine: MPMath.add,
  args: ['a', 'b']
}).exec({
  success: function (sum){
    console.log('Got result:', sum);
  }
});

Now you can use serial CLI arguments as inputs:

$ node ./add-numbers.js 2 3
# Got result: 5

License

MIT © Mike McNeil

Keywords

machine

FAQs

Package last updated on 15 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts