diff --git a/index.js b/index.js index 03f6d37..98b00af 100644 --- a/index.js +++ b/index.js @@ -1,40 +1,33 @@ #!/usr/bin/env node +'use strict'; /* - * index.js + * Gleech * Copyright (C) 2017 jkirchartz * * Distributed under terms of the GPL3.0 license. */ -'use strict'; var gleech = require('./dist/gleech.js'); -var vorpal = require('vorpal')(); - -vorpal.history('gleech'); - -vorpal -.command('glitch [operation] [parameters...]', - 'Glitches an image with optional type and parameters') -.action(function(args, callback) { - var input = args.input; - var output = args.output; - var operation = args.operation; - var parameters = args.parameters; +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](parameters); + image[operation].apply(this, parameters); } else if (operation && !parameters) { image[operation](); } else { - vorpal.log("please provide a function name"); + console.log("please provide a function name"); } image.write(output); }); - callback(); }); -vorpal.command('list', 'Lists available functions') -.action(function(args, callback) { +cmdr.command('list') +.description('Lists available functions') +.action(function() { var output = ""; output += ('\nGlitches:\n\n'); for (var prop in gleech.prototype) { @@ -44,16 +37,13 @@ vorpal.command('list', 'Lists available functions') } } output += ('\n\nJimp functions:\n\n'); - for (var prop in gleech.prototype) { - if (typeof gleech.prototype[prop] === 'function' && - ! gleech.prototype[prop].name){ - output += String(prop) + ' '; + for (var prop2 in gleech.prototype) { + if (typeof gleech.prototype[prop2] === 'function' && + ! gleech.prototype[prop2].name){ + output += String(prop2) + ' '; } } - vorpal.log(output); - callback(); + console.log(output); }); -vorpal.delimiter('gleech$').show(); - - +cmdr.version('0.1.0').parse(process.argv); diff --git a/package.json b/package.json index b8e7bb4..e42b956 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ } ], "dependencies": { - "jimp": "^0.2.27", - "vorpal": "^1.12.0" + "commander": "^2.11.0", + "jimp": "^0.2.27" }, "devDependencies": { "grunt": "^1.0.1", @@ -25,7 +25,7 @@ }, "scripts": { "test": "grunt && cd test && node test.js", - "gleech": "node index.js", + "gleech": "node index.js", "build": "grunt", "deploy": "git subtree push --prefix site origin gh-pages" }, @@ -39,7 +39,7 @@ "image processing", "aesthetic" ], - "license": "GPL 3.0", + "license": "GPL-3.0", "bugs": { "url": "https://github.com/jkirchartz/Glitchy3bitDither/issues" },