forked from mncaudill/3bitdither
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
user commander instead of vorpal (so it can be called from the comman…
…dline, instead of the "immersive cli")
- Loading branch information
1 parent
c83a48c
commit 4dbf9e6
Showing
2 changed files
with
22 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters