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.
yargs-unparser
Advanced tools
The yargs-unparser npm package is used to reverse the process of parsing arguments. It takes an argv object, like the one yargs or minimist would generate, and turns it back into a string of command-line arguments. This can be useful for debugging, logging, or recreating command lines for subprocesses.
Unparsing arguments
This feature allows you to take an argument object and convert it back into an array of command-line arguments.
const yargsUnparser = require('yargs-unparser');
const argv = { _: ['run'], 'file': 'test.js', 'verbose': true };
const unparsedArgs = yargsUnparser(argv);
console.log(unparsedArgs); // Output: ['run', '--file=test.js', '--verbose']
Minimist is a library for parsing command-line arguments. Unlike yargs-unparser, it does not unparse arguments but is commonly used for the initial parsing step that yargs-unparser would reverse.
Commander is a complete solution for node.js command-line interfaces. It is similar to yargs in that it helps with parsing arguments, but it does not have a built-in feature to unparse them like yargs-unparser.
Arg is a simple argument parsing library with a focus on performance. It does not have the unparse functionality but serves a similar initial purpose of parsing command-line arguments.
Converts back a yargs
argv object to its original array form.
Probably the unparser word doesn't even exist, but it sounds nice and goes well with yargs-parser.
$ npm install yargs-unparser --save
const unparse = require('yargs-unparser');
const parse = require('yargs-parse');
unparse(parse(['node', 'cli.js', '--no-boolean', '--number', '4', '--string', 'foo'], {
number: 'number',
string: 'string',
boolean: 'boolean',
}));
// ['node', 'cli.js', '--no-boolean', '--number', '4', '--string', 'foo']);
The second argument of unparse
accepts an options object:
aliases
: The aliases so that duplicate options aren't generatedNOTE: The returned array can be parsed again by yargs-parser
using the default configuration. If you used custom configuration that you want yargs-unparser
to be aware, please fill an issue.
$ npm test
$ npm test:watch
during development
FAQs
Converts back a yargs argv object to its original array form
We found that yargs-unparser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.