string-argv

WebJar for string-argv

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

string-argv
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

string-argv
WebJar for string-argv
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mccormicka/string-argv

Download string-argv

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/string-argv/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>string-argv</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/string-argv/
implementation 'org.webjars.npm:string-argv:0.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/string-argv/
implementation ("org.webjars.npm:string-argv:0.0.2")
'org.webjars.npm:string-argv:jar:0.0.2'
<dependency org="org.webjars.npm" name="string-argv" rev="0.0.2">
  <artifact name="string-argv" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='string-argv', version='0.0.2')
)
libraryDependencies += "org.webjars.npm" % "string-argv" % "0.0.2"
[org.webjars.npm/string-argv "0.0.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

What is it?

string-argv parses a string into an argument array to mimic process.argv. This is useful when testing Command Line Utilities that you want to pass arguments to and is the opposite of what the other argv utilities do.

Installation

npm install string-argv --save

Usage

// Typescript
import stringArgv from 'string-argv';

const args = stringArgv(
  '-testing test -valid=true --quotes "test quotes" "nested \'quotes\'" --key="some value" --title="Peter\'s Friends"',
  'node',
  'testing.js'
);

console.log(args);
// Javascript
var { parseArgsStringToArgv } = require('string-argv');

var args = parseArgsStringToArgv(
    '-testing test -valid=true --quotes "test quotes" "nested \'quotes\'" --key="some value" --title="Peter\'s Friends"',
    'node',
    'testing.js'
);

console.log(args);
/** output
[ 'node',
  'testing.js',
  '-testing',
  'test',
  '-valid=true',
  '--quotes',
  'test quotes',
  'nested \'quotes\'',
  '--key="some value"',
  '--title="Peter\'s Friends"' ]
  **/

params

required: arguments String: arguments that you would normally pass to the command line.

optional: environment String: Adds to the environment position in the argv array. If ommitted then there is no need to call argv.split(2) to remove the environment/file values. However if your cli.parse method expects a valid argv value then you should include this value.

optional: file String: file that called the arguments. If omitted then there is no need to call argv.split(2) to remove the environment/file values. However if your cli.parse method expects a valid argv value then you should include this value.

Versions

Version
0.0.2