codenothing / argv Goto Github PK
View Code? Open in Web Editor NEWNode based command line argument parser
Home Page: http://codenothing.github.com/argv/
License: MIT License
Node based command line argument parser
Home Page: http://codenothing.github.com/argv/
License: MIT License
I try to put an array of modules in argv.mod(), but it doesn't work the console said :
Cannot read property 'description' of undefined.
I am new to js I can only know the mod function use some recursive call along with the option function to decompose the module object. Could anyone share how to do it? I am not sure this function is supported
sometimes, we have to waring or notice user how important about the command line type.
like this:
--version
displays version info
xxx.js --version
--remove, -r
remove the project --- (!important, be careful use this) <= red color
xxx.js --remve or xxx.js -r
This could very well be a personal choice of some sort, but I feel obliged to provide at least a little information when I get an NPM warning:
npm WARN package.json [email protected] No repository field.
If you would care to you can add repository information to your package.json:
{
"repository": {
"type": "git",
"url": "https://github.com/codenothing/argv.git"
}
}
because why not 😄
Given this code:
import argv from 'argv';
argv.option([
{ name: 'port', type: 'int' },
{ name: 'host', type: 'string' },
]);
const args = argv.run();
console.log(args);
It doesn't capture the values without an =
node bug.js --port 6969 --host 0.0.0.0
{
targets: [ '6969', '0.0.0.0' ],
options: { port: NaN, host: 'true' }
}
It does with with an =
node bug.js --port=6969 --host=0.0.0.0
{ targets: [], options: { port: 6969, host: '0.0.0.0' } }
But the docs shows an example using it with a space. Is there a setting I'm not seeing? Or a bug?
Can I add an option with a default value?
Looks like the CI build is failing due to some outdated dependencies:
see https://travis-ci.org/codenothing/argv/builds/219080292
preventing #8 from merging automatically
I have a NodeJS program that uses the "argv" package.
When, in the command line, you specify a unexpected (a wrong) parameter for my program, it end its execution.
I have checked that, and I have discovered that it's because "argv" call to "process.exit".
Could you change the implementation of "agv" for making that behaviour configurable?
I believe that is a bad practice that a package calls to "process.exit"; that call sould be issued only by the main program.
When you put two or more dollar '$' chars into an argument:
#index.js
var argv = require( 'argv' );
let options = [{
name: 'comment',
type: 'string',
}];
var args = argv.option( options ).run();
console.log(args.options.comment);
The you do on terminal:
node index.js --comment="Hey, do you want some $$$$"
Expected result:
"Hey, do you want some $$$$"
Result:
"Hey, do you want some 114349114349"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.