Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stdio

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stdio - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

license

4

CHANGES.md
# Changes
## 0.2.7
* Positional arguments constraints support added, by mean of `_meta_` argument settings.
## 0.2.5

@@ -4,0 +8,0 @@

@@ -250,2 +250,5 @@ 'use strict';

for (option in config) {
if (option === '_meta_') {
continue;
}
if (config[option].mandatory && !(option in cmdOptions)) {

@@ -275,2 +278,23 @@ if (testing) {

// Check expected positional arguments are provided
var providedArgs = 0;
if (Array.isArray(cmdOptions.args) && cmdOptions.args.length > 0) {
providedArgs = cmdOptions.args.length;
}
if (config._meta_ && config._meta_.args && providedArgs !== config._meta_.args) {
console.log('%d positional arguments (without option flag) are required, but %d have been provided.', config._meta_.args, providedArgs);
printHelpMessage(config, helpTail, programName);
process.exit(-1);
}
if (config._meta_ && config._meta_.minArgs && providedArgs < config._meta_.minArgs) {
console.log('At least %d positional arguments (without option flag) are required, but %d have been provided.', config._meta_.minArgs, providedArgs);
printHelpMessage(config, helpTail, programName);
process.exit(-1);
}
if (config._meta_ && config._meta_.maxArgs && providedArgs > config._meta_.maxArgs) {
console.log('Too many positional arguments (without option flag) provided. The maximum allowed is %d, but %d have been provided.', config._meta_.maxArgs, providedArgs);
printHelpMessage(config, helpTail, programName);
process.exit(-1);
}
// Apply default values

@@ -308,2 +332,5 @@ for (option in config) {

for (o in options) {
if (o === '_meta_') {
continue;
}
if (options.hasOwnProperty(o)) {

@@ -310,0 +337,0 @@ var ops = ' ', i;

2

package.json
{
"name": "stdio",
"version": "0.2.6",
"version": "0.2.7",
"description": "Standard input/output management with NodeJS",

@@ -5,0 +5,0 @@ "keywords": ["input", "console", "output", "terminal", "system", "arguments", "cli"],

@@ -96,6 +96,28 @@ Module for standard input/output management with nodejs.

var ops = stdio.getopt({
meta: {args: 2, default: ['a', 'b']}
something: {args: 2, default: ['a', 'b']}
});
```
#### Mandatory positional arguments
If your program has to receive some mandatory positional arguments (extra arguments without an option flag), you can specify it when calling `getopt()`:
```
var ops = stdio.getopt({
_meta_: {args: 2}
});
```
```
var ops = stdio.getopt({
_meta_: {minArgs: 1}
});
```
```
var ops = stdio.getopt({
_meta_: {maxArgs: 5}
});
```
#### Print usage

@@ -102,0 +124,0 @@

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