
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Create a command-line argument from a string or string (key) and value.
npm i to-arg --save
var toArg = require('to-arg');
toArg('abc');
//=> '--abc'
toArg('abc', true);
//=> '--abc'
toArg('abc', 'xyz');
//=> '--abc=xyz'
toArg('abc', 'true');
//=> '--abc=true'
toArg('abc', 10);
//=> '--abc=10'
casing
Keys that are camelcase or contain spaces will be dash-cased:
toArg('fooBar');
//=> '--foo-bar'
toArg('a b c');
//=> '--a-b-c'
toArg('A');
//=> '--a'
var obj = {
foo: 'bar',
abc: true,
xyz: 10,
one: false
};
var args = Object.keys(obj).map(function (key) {
return toArg(key, obj[key]);
});
//=> ['--foo=bar', '--abc', '--xyz=10', '--no-one']
When the value is false
an inverted flag is created by default:
toArg('a', false);
//=> '--no-a'
To disable inversion, pass false
on the options:
toArg('a', false, {invert: false});
//=> '--a'
Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
This was inspired by grunt.option.
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on April 17, 2015.
FAQs
Create a command-line argument from a string or string (key) and value.
The npm package to-arg receives a total of 219 weekly downloads. As such, to-arg popularity was classified as not popular.
We found that to-arg demonstrated a not healthy version release cadence and project activity because the last version was released 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.