bitpay/copay — pull request #39 by ryanxcharles (2014-04-14 21:29:10+00:00)
Title: WIP: 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.

Examples:

```
> copay getCommands
[
"echo",
"getCommands",
"getPublicKeyRingId"
]
> copay echo test
"test"
> copay getPublicKeyRingId
"23ae7bbf29bbfc92"

```

And if you use incorrect parameters:
```
ryanxcharles@rxc-h.local> ./bin/copay echo

/Users/ryanxcharles/dev/copay/bin/Copay.js:57
throw new Error('Invalid arguments');
^
Error: Invalid arguments
at checkArgs (/Users/ryanxcharles/dev/copay/bin/Copay.js:57:11)
at Copay.echo (/Users/ryanxcharles/dev/copay/bin/Copay.js:62:3)
at Copay._command (/Users/ryanxcharles/dev/copay/bin/Copay.js:38:28)
at main (/Users/ryanxcharles/dev/copay/bin/copay:22:9)
at Object. (/Users/ryanxcharles/dev/copay/bin/copay:31:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)

```
...in the future, errors will be handled more nicely.

The idea of this is that the same basic interface should also work for RPC so that we won't have to duplicate code. Soon, Copay.js will link directly to Wallet.js and not PublicKeyRing.js, and will just provide access to Wallet.js.