Skip to content

mattdesl/subarg-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

subarg-replace

unstable

Regex replace on subarg list.

For example, given the following command:

node test.js --foo --debug -t [ plugin --debug ]

We can replace only the top-level --debug like so:

var args = parse(process.argv.slice(2), {
  match: /--debug/,
  replace: '--no-debug'
})

var argv = require('subarg')(args)
argv.debug === false
argv.plugin.debug === true

If the result is an empty string, the argument is skipped.

Usage

NPM

args = parse(args, opt)

In an arg list, replaces flags with given options:

  • match the regex to match, or a pair of regexes to match a flags like [ '--debug', 'eval' ]
  • replace the value to replace the argument(s) with
  • depth the depth at which this replacement should occur, default 0

If a pair is given and a match is found, the pair is replaced by the single replace string.

License

MIT, see LICENSE.md for details.

About

regex replace on subarg list

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published