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.
try to package to be importable or run from the CLI
- Loading branch information
1 parent
4dbf9e6
commit 5eecc3b
Showing
3 changed files
with
56 additions
and
45 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
/* | ||
* Gleech | ||
* Copyright (C) 2017 jkirchartz <[email protected]> | ||
* | ||
* 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 <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].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); |
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,49 +1,7 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
/* | ||
* Gleech | ||
* index.js | ||
* Copyright (C) 2017 jkirchartz <[email protected]> | ||
* | ||
* 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 <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].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'); |
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