Socket
Socket
Sign inDemoInstall

process.argv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

process.argv - npm Package Compare versions

Comparing version 0.1.0 to 0.6.0

LICENSE

20

package.json
{
"name": "process.argv",
"description": "light-weight command line arguments parser for cli application",
"version": "0.1.0",
"description": "light-weight CLI arguments parser",
"version": "0.6.0",
"author": "@kawanet",

@@ -10,10 +10,17 @@ "bugs": {

"dependencies": {
"obop": "^0.0.12"
"obop": "^0.2.0"
},
"devDependencies": {
"jshint": "^2.9.2",
"mocha": "^2.5.3"
"jshint": "^2.12.0",
"mocha": "^8.2.0"
},
"files": [
"LICENSE",
"README.md",
"process.argv.js",
"types/process.argv.d.ts"
],
"homepage": "https://github.com/kawanet/process.argv#readme",
"jshintConfig": {
"esversion": 6,
"mocha": true,

@@ -39,3 +46,4 @@ "node": true,

"test": "npm run jshint && npm run mocha"
}
},
"typings": "./types/process.argv.d.ts"
}
# process.argv.js
light-weight command line arguments parser for cli application
light-weight CLI arguments parser
[![Node.js CI](https://github.com/kawanet/process.argv/workflows/Node.js%20CI/badge.svg?branch=master)](https://github.com/kawanet/process.argv/actions/)
[![npm version](https://badge.fury.io/js/process.argv.svg)](https://www.npmjs.com/package/process.argv)
## Synopsis
```sh
```js
#!/usr/bin/env node
var argv = require("process.argv")(process.argv.slice(2));
const argv = require("process.argv");
const processArgv = argv(process.argv.slice(2));
// default options --foo=AAA --bar-buz=BBB
var config = {
// apply CLI options onto defaults: --foo=AAA --bar-buz=BBB
const config = processArgv({
foo: "AAA",

@@ -18,7 +22,4 @@ bar: {

}
};
});
// apply options given on CLI arguments
config = argv(config);
// show help message if --help given

@@ -31,8 +32,37 @@ if (config.help) {

// rest of CLI arguments
var files = config["--"] || [];
files.forEach(function(file) {
console.log(file);
const args = config["--"] || [];
args.forEach(function(arg) {
console.log(arg);
});
```
CLI
```sh
node cli.js --foo=aaa --bar-buz=bbb file1 file2 file3
```
## TypeScript
```ts
import argv from "process.argv";
const processArgv = argv(process.argv.slice(2));
interface Config {
foo: string;
bar: {
buz: string;
},
qux?: boolean;
}
const config = processArgv<Config>({
foo: "AAA",
bar: {
buz: "BBB"
}
});
```
## FAQ

@@ -58,3 +88,3 @@

A. `.` is the special special character used internally. It's not available in a key.
A. `.` is the special character used internally. It's not available in a key.

@@ -64,3 +94,3 @@ ## Install

```sh
npm install -g process.argv
npm install --save process.argv
```

@@ -76,3 +106,3 @@

Copyright (c) 2016 Yusuke Kawasaki
Copyright (c) 2016-2020 Yusuke Kawasaki

@@ -79,0 +109,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc