JSPM

simple-cli-parser

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q52241F
  • License ISC

child_process via spawn parser, very simple.

Package Exports

  • simple-cli-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simple-cli-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

simple-cli-parser

Build Status

A simple parser for a spawning child_process, with promises/ES6 style classes.

Install

npm install simple-cli-parser --save

Usage

To see the result of ls -la.

'use strict';

const cli = require('simple-cli-parser');

let ls = new cli([ 'ls', '-la', __dirname ])
    .then(res => { console.log('Success!', res); })
    .catch(err => { console.log('Failed!'); });

To stream the result of a curl download (to check current percentage).

'use strict';

const cli = require('simple-cli-parser'),
    currentPercentage = data => { // Optional function for checking status
        let percent = parseFloat(data, 10);
        if (!isNaN(percent) && percent > 0){ console.log(percent + '%'); }
    };

let download = new cli([ 'curl', '-O', 'http://speedtest.ftp.otenet.gr/files/test10Mb.db', '-#' ], currentPercentage)
    .then(res => { console.log('Success!', res); })
    .catch(err => { console.log('Failed!'); });