Skip to content

Commit

Permalink
user commander instead of vorpal (so it can be called from the comman…
Browse files Browse the repository at this point in the history
…dline, instead of the "immersive cli")
  • Loading branch information
JKirchartz committed Nov 4, 2017
1 parent c83a48c commit 4dbf9e6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
46 changes: 18 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
#!/usr/bin/env node
'use strict';
/*
* index.js
* Gleech
* Copyright (C) 2017 jkirchartz <[email protected]>
*
* 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 <input> <output> [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 <input> <output> [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) {
Expand All @@ -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);
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand All @@ -39,7 +39,7 @@
"image processing",
"aesthetic"
],
"license": "GPL 3.0",
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/jkirchartz/Glitchy3bitDither/issues"
},
Expand Down

0 comments on commit 4dbf9e6

Please sign in to comment.