add initial command-line interface
You can see commands by running "copay getCommands" Types are enforced - right now only strings work. This is so that types can be coerced from the command-line correctly. Number of arguments are also enforced. In the future you will be able to pass in JSON objects as arguments and they will be translated to real objects.
This commit is contained in:
parent
dca1ffd226
commit
26073921fb
2 changed files with 150 additions and 0 deletions
32
bin/copay
Executable file
32
bin/copay
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env node
|
||||
var Copay = require('./Copay.js');
|
||||
var commander = require('commander');
|
||||
|
||||
var main = function() {
|
||||
|
||||
commander
|
||||
.version("0.0.1")
|
||||
.option('-f, --file [file]', 'AES encrypted data file', 'copay.json.aes')
|
||||
.option('-p, --pass [passphrase]', 'AES wallet passphrase')
|
||||
.option('-c, --client', 'Issue command over RPC to copay 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 copay = new Copay(commander);
|
||||
|
||||
var args = commander.args;
|
||||
|
||||
copay._command(args[0], args.slice(1), function(err, result) {
|
||||
if (err)
|
||||
return console.log("" + err);
|
||||
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
});
|
||||
};
|
||||
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue