Executable program.

Generates SVG badges.
This commit is contained in:
Thaddee Tyl 2014-01-07 15:52:59 +01:00
parent 9d29a636f3
commit 5e2a7d478e
2 changed files with 43 additions and 1 deletions

41
gh-badge.js Executable file
View File

@ -0,0 +1,41 @@
var badge = require('./badge.js');
var colorscheme = require('./colorscheme.json');
if (process.argv.length < 4) {
console.log('Usage: badge subject status :[colorscheme]');
console.log('Or: badge subject status right-color [left-color]');
console.log();
console.log(' colorscheme: one of '
+ Object.keys(colorscheme).join(', ') + '.');
console.log(' left-color, right-color:');
console.log(' #xxx (three hex digits)');
console.log(' #xxxxxx (six hex digits)');
console.log(' color (CSS color)');
console.log();
console.log('Eg: badge grown cactus :green');
console.log();
process.exit();
}
var subject = process.argv[2];
var status = process.argv[3];
var color = process.argv[4] || ':green';
var colorA = process.argv[5];
var badgeData = {text: [subject, status]};
function sixHex(s) { return /^[0-9a-fA-F]{6}$/.test(s); }
if (color[0] === ':') {
color = color.slice(1);
if (colorscheme[color] == null) {
// Colorscheme not found.
console.error('Invalid color scheme.');
process.exit(1);
}
badgeData.colorscheme = color;
} else {
badgeData.colorB = color;
if (colorA) { badgeData.colorA = colorA; }
}
badge(badgeData, function(svg) { console.log(svg); });

View File

@ -1,6 +1,6 @@
{
"name": "gh-badges",
"version": "0.1.0",
"version": "0.1.1",
"description": "GitHub badges implemented in SVG.",
"keywords": ["GitHub", "badge", "SVG", "image"],
"homepage": "http://b.adge.me",
@ -23,5 +23,6 @@
"es6-promise": "~0.1.1",
"camp": "~13.11.9"
},
"bin": { "badge": "./gh-badge.js" },
"engines": { "node": "0.10.x" }
}