Wallet/bin/copay
Ryan X. Charles dd2e8c585e move Copay.js -> API.js, and handle case of no command better
* API is a more appropriate name for what this is. It is intended to be the
 interface used by external apps.
* The case where you run "copay" with no command is now handled better.
2014-04-15 14:57:06 -03:00

36 lines
1 KiB
JavaScript
Executable file

#!/usr/bin/env node
var API = require('../API.js');
var commander = require('commander');
var main = function() {
commander
.version("0.0.1")
.option('-f, --file [file]', 'AES encrypted data file', 'api.json.aes')
.option('-p, --pass [passphrase]', 'AES wallet passphrase')
.option('-c, --client', 'Issue command over RPC to api daemon')
.option('-d, --daemon', 'Run as daemon accepting RPC commands')
.option('--rpcport [port]', 'RPC port [18332]', Number, 18332)
.option('--rpcuser [user]', 'RPC user [user]', String, 'user')
.option('--rpcpass [password]', 'RPC password [pass]', String, 'pass')
.parse(process.argv);
var api = new API(commander);
var args = commander.args;
try {
api._command(args[0], args.slice(1), function(err, result) {
if (err)
return console.log("" + err);
console.log(JSON.stringify(result, null, 2));
});
} catch (err) {
console.log("" + err);
}
};
if (require.main === module) {
main();
}