Closed xgqfrms-GitHub closed 7 years ago
CLI
https://sfantasy.gitbooks.io/node-in-action/content/zh/cli/
https://www.sitepoint.com/javascript-command-line-interface-cli-node-js/
https://github.com/sitepoint-editors/ginit
https://developer.atlassian.com/blog/2015/11/scripting-with-node/
http://javascriptplayground.com/blog/2015/03/node-command-line-tool/
Our goal will be to write a CLI app to list files and directories.
我们的目标是编写一个CLI应用程序来列出文件和目录
https://medium.freecodecamp.com/writing-command-line-applications-in-nodejs-2cf8327eee2
npm link
#!/usr/bin/env node
var program = require('commander');
console.log('Node CLI');
program.version('1.1.1').parse(process.argv);
console.log('Node CLI', process.argv[0]);
console.log('Node CLI', process.argv[1]);
console.log('Node CLI', process.argv[2]);
{
"name": "hello",
"bin": {
"hello": "hello",
"nc": "nodecli"
},
"dependencies": {
"commander": "^2.9.0"
}
}
$ npm link
$ nc
https://segmentfault.com/a/1190000008714075
http://visionmedia.github.io/superagent/
not exactly, just set
#!/usr/bin/env node
#!/usr/bin/env node
#!/usr/bin/env node
https://github.com/xgqfrms-GitHub/Node-CLI-Tools/issues/2
https://node-cli-tools.xgqfrms.xyz/
#!/usr/bin/env node
#!/usr/bin/env node
C:\Users\xray\AppData\Roaming\npm-cache_logs\2017-06-11T18_24_42_614Z-debug.log
https://www.npmjs.com/package/request
https://sfantasy.gitbooks.io/node-in-action/content/zh/cli/request.html
var colors = require('colors');
https://www.npmjs.com/package/colors
if (type && types.includes(type)) {
// generator files
} else {
// console.error(`unknown type`, type);
// color
console.log(`unknown type`.bgBlack.magenta.bold.italic, `"` + `${type}`.red.underline + `"`);
console.log(`for more details, click link:`.bgGreen.black, `https://github.com/Marak/colors.js`.green);
}
blogs
https://medium.freecodecamp.com/writing-command-line-applications-in-nodejs-2cf8327eee2