Comparing version 0.1.0 to 0.2.0
@@ -124,3 +124,3 @@ { | ||
" ", | ||
"\/", | ||
"\\/", | ||
"/ " | ||
@@ -157,3 +157,8 @@ ], | ||
" " | ||
], | ||
" ": [ | ||
" ", | ||
" ", | ||
" " | ||
] | ||
} |
18
ascli.js
@@ -80,6 +80,7 @@ /* | ||
* @param {string=} appendix Title appendix | ||
* @returns {string} | ||
* @returns {Function} ascli | ||
*/ | ||
ascli.banner = function(title, appendix) { | ||
console.log(ascli(title, appendix)); | ||
return ascli; | ||
}; | ||
@@ -134,10 +135,13 @@ | ||
* @param {Array.<string>=} argv | ||
* @returns {{node: *, script: null, argv: Array, opt: {}}} | ||
* @returns {{node: string, script: string, argv: Array.<string>, opt: Object.<string,boolean|string>}} | ||
*/ | ||
ascli.opt = function(argv) { | ||
var opt={},arg,p;argv=Array.prototype.slice.call(argv||process.argv);for(var i=2;i<argv.length;i++)if(argv[i].charAt(0)=='-') | ||
((p=(arg=(""+argv.splice(i--,1)).replace(/^[\-]+/,'')).indexOf("="))>0?opt[arg.substring(0,p)]=arg.substring(p+1):opt[arg]=true); | ||
return {'node':argv[0],'script':argv[1],'argv':argv.slice(2),'opt':opt}; | ||
}; | ||
ascli.optjs = require("optjs"); | ||
// Pre-run it | ||
var opt = ascli.optjs(); | ||
ascli.node = opt.node; | ||
ascli.script = opt.script; | ||
ascli.argv = opt.argv; | ||
ascli.opt = opt.opt; | ||
// Expose colour.js | ||
@@ -144,0 +148,0 @@ ascli.colour = ascli.colors = colour; |
{ | ||
"name": "ascli", | ||
"description": "A uniform foundation for unobtrusive (ASCII art in) cli apps.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"author": "Daniel Wirtz <dcode@dcode.io>", | ||
@@ -21,3 +21,4 @@ "repository": { | ||
"dependencies": { | ||
"colour": "latest" | ||
"colour": "latest", | ||
"optjs": "latest" | ||
}, | ||
@@ -24,0 +25,0 @@ "scripts": { |
![ascli](https://raw.github.com/dcodeIO/ascli/master/ascli.png) | ||
===== | ||
A uniform foundation for unobtrusive (ASCII art in) cli apps. | ||
**Why?** Some of us are not only programmers but also part-time artist. So am I. This is good. However, to limit myself | ||
a bit to a straight look of my CLI apps, I've created ascli based on the thought of not making things too fancy but | ||
still looking good. So, basically, this package is meant to be used by me but if you like my interpretation of | ||
unobtrusiveness and ease-of-use ... You are welcome! | ||
@@ -9,7 +12,2 @@ <p align="center"> | ||
**Why?** Some of us are not only programmers but also part-time artist. So am I. This is good. However, to limit myself | ||
a bit to a straight look of my CLI apps, I've created ascli based on the thought of not making things too fancy but | ||
still looking good. So, basically, this package is meant to be used by me but if you like my interpretation of | ||
unobtrusiveness and ease-of-use ... You are welcome! | ||
Installation | ||
@@ -23,3 +21,3 @@ ------------ | ||
var ascli = require("ascli").app("myApp"); | ||
ascli.banner(ascli.name.green.bold, "v1.0.0 by Foo Bar <foobar@example.com>"); | ||
ascli.banner(ascli.appName.green.bold, "v1.0.0 by Foo Bar <foobar@example.com>"); | ||
console.log("Hello!"); | ||
@@ -55,3 +53,9 @@ // If it worked: | ||
------------------------------ | ||
[opt.js](https://github.com/dcodeIO/opt.js) is included as `ascli.opt()`. | ||
[opt.js](https://github.com/dcodeIO/opt.js) will be pre-run on the `ascli` namespace and also exposed as `ascli.optjs()`. | ||
```js | ||
ascli.node // Node executable | ||
ascli.script // Executed script | ||
ascli.opt // Options as a hash | ||
ascli.argv // Remaining non-option arguments | ||
``` | ||
@@ -58,0 +62,0 @@ License |
var ascli = require("../ascli.js").app("myapp"); | ||
ascli.banner("straiht".green.bold, "through ascli"); | ||
ascli.banner("staying straight".green.bold, "v1.0.0 through ascli"); | ||
console.log("Hello world!".white.bold); | ||
console.log("...of ascli"); | ||
console.log("...of ascli\n"); | ||
console.log("Command line arguments".white.bold); | ||
console.log(ascli.opt, ascli.argv); | ||
ascli.ok("yep, that worked."); |
Sorry, the diff of this file is not supported yet
26969
300
62
2
+ Addedoptjs@latest
+ Addedoptjs@3.2.2(transitive)