diff --git a/bin/gleech b/bin/gleech new file mode 100644 index 0000000..877bddb --- /dev/null +++ b/bin/gleech @@ -0,0 +1,52 @@ +#!/usr/bin/env node +'use strict'; +/* + * Gleech + * Copyright (C) 2017 jkirchartz + * + * Distributed under terms of the GPL3.0 license. + */ +var gleech = require('../dist/gleech.js'); +var cmdr = require('commander'); +var pkg = require('../package.json'); + +cmdr +.command('glitch [operation] [parameters...]') +.description('Glitches an image with optional type and parameters') +.action(function(input, output, operation, parameters) { + gleech.read(input, function(err, image) { + if (operation && parameters) { + image[operation].apply(this, parameters); + } else if (operation && !parameters) { + image[operation](); + } else { + console.log("please provide a function name"); + } + image.write(output); + }); +}); + +cmdr.command('list') +.description('Lists available functions') +.action(function() { + var output = ""; + output += ('\nGlitches:\n\n'); + for (var prop in gleech.prototype) { + if (typeof gleech.prototype[prop] === 'function' && + gleech.prototype[prop].name){ + output += gleech.prototype[prop].name + ' '; + } + } + output += ('\n\nJimp functions:\n\n'); + for (var prop2 in gleech.prototype) { + if (typeof gleech.prototype[prop2] === 'function' && + ! gleech.prototype[prop2].name){ + output += String(prop2) + ' '; + } + } + console.log(output); +}); + +cmdr.version(pkg.version) +.description(pkg.description) +.parse(process.argv); diff --git a/index.js b/index.js index 98b00af..f6001be 100644 --- a/index.js +++ b/index.js @@ -1,49 +1,7 @@ -#!/usr/bin/env node -'use strict'; /* - * Gleech + * index.js * Copyright (C) 2017 jkirchartz * - * Distributed under terms of the GPL3.0 license. + * Distributed under terms of the NPL (Necessary Public License) license. */ -var gleech = require('./dist/gleech.js'); -var cmdr = require('commander'); - -cmdr -.command('glitch [operation] [parameters...]') -.description('Glitches an image with optional type and parameters') -.action(function(input, output, operation, parameters) { - gleech.read(input, function(err, image) { - if (operation && parameters) { - image[operation].apply(this, parameters); - } else if (operation && !parameters) { - image[operation](); - } else { - console.log("please provide a function name"); - } - image.write(output); - }); -}); - -cmdr.command('list') -.description('Lists available functions') -.action(function() { - var output = ""; - output += ('\nGlitches:\n\n'); - for (var prop in gleech.prototype) { - if (typeof gleech.prototype[prop] === 'function' && - gleech.prototype[prop].name){ - output += gleech.prototype[prop].name + ' '; - } - } - output += ('\n\nJimp functions:\n\n'); - for (var prop2 in gleech.prototype) { - if (typeof gleech.prototype[prop2] === 'function' && - ! gleech.prototype[prop2].name){ - output += String(prop2) + ' '; - } - } - console.log(output); -}); - -cmdr.version('0.1.0').parse(process.argv); +module.exports = require('./dist/gleech'); diff --git a/package.json b/package.json index e42b956..a176953 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "description": "Image glitching & dithering in NodeJS", "main": "index.js", + "bin": "./bin/gleech", "contributors": [ { "name": "Nolan Caudill",