1.0.0 • Published 5 years ago

exargs v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

exargs

Expand your arguments, expand your mind.

Basically a cli wrapper for dargs that allows you to easily externalize arguments and flags for passing to cli's that don't support .*rc or other configuration files.

Installation

npm install --save-dev exargs
# or
yarn add exargs

Usage

This utility depends on argument expansion in order to work properly.

// package.json

{
  "scripts": {
    "start:long": "mycmd --with=alot,of,arguments,oh,so,long --why=do,i,have,all,of,this,in,here --what=have,i,done,to,deserve,this",
    "start:short": "mycmd $(exargs .mycmdrc)"
  }
}
// .mycmdrc

{
  "with": "alot,of,arguments,oh,so,long",
  "why": "do,i,have,all,of,this,in,here",
  "what": "have,i,done,to,deserve,this"
}

Options

All of the options accepted by dargs can be passed to exargs. The only way to pass these options currently is to add a $ property to the configuration file you have specified.

// .mycmdrc

{
  "$": {
    "combine": ["property"]
  },

  "property": ["one", "two"]
}

There are also some options added to make exargs more configurable:

  • combine Array - specify fields which should be rolled up into a single string to avoid dargs generating multiple arguments.

combine

Without combine:

{
  "with": ["alot", "of", "arguments", "oh", "so", "long"]
}

// yields: --with=alot --with=of --with=arguments --with=oh --with=so --with=long

With combine:

{
  "$": {
    "combine": ["with"]
  },
  "with": ["alot", "of", "arguments", "oh", "so", "long"]
}

// yields: --with=alot --with=of --with=arguments --with=oh --with=so --with=long