Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Module for input/output management with nodejs.
To install the most recent release from npm, run:
npm install stdio
You can do many things with this module
var stdio = require('stdio');
var ops = stdio.getopt({
'check': {key: 'c', args: 2, description: 'What this option means'},
'map': {key: 'm', description: 'Another description', mandatory: true},
'kaka': {key: 'k', args: 2, mandatory: true},
'ooo': {key: 'o'}
});
console.log(ops);
If you run the previous example with the command
node pruebas.js -c 23 45 88 --map -k 23 44 cosa
Program output will be:
{ check: [ '23', '45' ],
args: [ '88', 'cosa' ],
map: true,
kaka: [ '23', '44' ] }
So you can check options:
if(ops.map){
// Your action
}
if(ops.kaka){
// Your action, using ops.kaka[0] or ops.kaka[1] or...
}
As you can see, every option in ops
object can has 3 different type of values:
true
if it has been specified without an args
attribute.string
if it has been specified with args: 1
.string
array, if it has been specified with args
>= 2.This module can generate an usage message automatically. You can use it when user specifies --help
option, which is automatically supported. This code:
var stdio = require('stdio');
var ops = stdio.getopt({
una: {description: 'Sets something to some value', key: 'u', args: 2, mandatory: true},
otra_muy_larga: {description: 'A boolean flag', key: 'o', mandatory: true},
una_sin_desc: {description: 'Another boolean flag'},
ultima: {description: 'A description', key: 'u', args: 1}
}, '[FILE1] [FILE2] ...'); // Optional extra arguments description
will produce the following output (if it is called with --help
flag):
USAGE: node something.js [OPTIONS] [FILE1] [FILE2] ...
-u, --una <ARG1> <ARG2> Sets something to some value (mandatory)
-o, --otra_muy_larga A boolean flag (mandatory)
--una_sin_desc Another boolean flag
-u, --ultima <ARG1> A description
If a non-spected option is given or a mandatory option is not, an error (followed by the usage message) will be shown, finishing your program automatically. It's cool, isn`t it?
var stdio = require('stdio');
stdio.read(function(data){
console.log(data);
});
This simple line:
stdio.printf('example %d: %s is %j\n', 2, 'any', {a: 2, b: [0, 2, 8], c: 'str'});
will produce the following output:
example 2: any is {"a":2,"b":[0,2,8],"c":"str"}
You can use %s
for strings, %d
for numbers (integer or floating-point ones), and %j
for JSON objects.
To run tests, use the following command from module's root:
npm test
-abc
instead of -a -b -c
.true
, a single string
or an array of strings
. Much easier to use than in previous releases (but incompatible with them, so be careful updating).stdio
moduleThe following projects are currently using stdio
module:
If you use this module in your project, please, let us know.
FAQs
Standard input/output manager for Node.js
The npm package stdio receives a total of 17,400 weekly downloads. As such, stdio popularity was classified as popular.
We found that stdio demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.