Skip to content

Parse a string into an argument array, do the job like `process.argv` for us.

License

Notifications You must be signed in to change notification settings

vikiboss/string2argv

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

string2argv

Parse a string into an argument array, do the job like process.argv for us.

This is a fork from string-argv, changes in this fork:

  • export extra string2argv & str2argv aliases.
  • change export { xx as default } to export default xx.
  • compatible with both ESM and CJS (by the change above).

Usage

ESM

import { string2argv } from 'string2argv'

const commandLineString = 'echo a b c -rvf --name "demo name"'

// output: [ 'echo', 'a', 'b', 'c', '-rvf', '--name', 'demo name' ]
console.log(string2argv(commandLineString))

CJS

const { default: string2argv } = require('string2argv')

const commandLineString = 'echo a b c -rvf --name "demo name"'

// output: [ 'echo', 'a', 'b', 'c', '-rvf', '--name', 'demo name' ]
console.log(string2argv(commandLineString))

About

Parse a string into an argument array, do the job like `process.argv` for us.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.3%
  • TypeScript 28.7%