This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

string-to-argv.js

1.1.2 • Public • Published

Parse String to ARGV as object

Parse a string of a unix-like command line and parse it into a more usable Object

Usage in node

  let Parser = require('string-to-argv.js')
  let parsed = new Parser('cmd -z -c -v -flag1 123 -p -f test --depth=0 -s --string=noquotes --flagstring="with spaces" source/ dest/')
  // @return
  {
    raw: 'cmd -z -c -v -flag1 123 -p -f test --depth=0 -s --string=noquotes --flagstring="with spaces" source/ dest/',
    command: 'cmd',
    _: [ 'source/', 'dest/' ],
    z: true,
    c: true,
    v: true,
    flag1: '123',
    p: true,
    f: 'test',
    depth: '0',
    s: true,
    string: 'noquotes',
    flagstring: 'with spaces'
  }

##Usage in Browser

  <script src="node_modules/string-to-argv.js/dist/Parser.js"></script>
  <script>
    var Parser = new Parser(/* ... */)
    // ...
  </script>

Know Issue

  • nesting quotes in stringed flag not implemented.

##Error

  try{
    let parsed = new Parser() // or empty string
  } catch(e) {
    console.log(e.message)
  }
  //> 'Parser: command provided is empty.'

###Dev

Source must be compiled to use with es2015

Run npm install or yarn install

Build with npm run build

Test with npm test

Package Sidebar

Install

npm i string-to-argv.js

Weekly Downloads

3

Version

1.1.2

License

ISC

Last publish

Collaborators

  • simonecorsi