TODAKit CLI
The TODA CLI is designed to allow hands-on exploration, debugging, and development of TODA files for power users and application engineers. It strives to follow the POSIX philosophy of defaulting to standard input/output streams, with flags to provide other backends and input or storage facilities. The CLI is being rapidly expanded to become the default development console of the TODA ecosystem, suitable for use within system operations, cron jobs, and other batch processes.
Setup
npm install -g todajs
Quickstart
Runtoda create --empty | toda historyto generate a simple file pipe its TODA-formatted output to the history tool.
$ toda create --empty | toda history twist 4146cba7b11a637e876bd8bc5de1a68fd6cf16b59b46d8cbde2405d41728a833ae tether 00 reqs 00 sats 00 rigging 00 shield 00 prev 00 cargo 00Adding
--jsonto the
historycommand will format results in JSON:
$ toda create --require 4166278f9f242a9752255237a46117248f8f716ecc554735e40c3638474d8dc057 --rigging 411c3436751e30e42043b29c4aa9f969d681b03c3273322a798aa68af152450124 --shield 417eeb707d0ac1b74e84ccd029024484f118985636727c5b3aab95e97f80fbab73 --tether 41bddef16b2f8862c1913e5a607d18fdc24b616af0ace55c63f41868d0a2414972 --empty | toda history --json [ { "twist": "413bfc067165c3afebe5740e73887cedb616a09eff94186ed4dd710dc483582554", "sats": "00", "prev": "00", "tether": "41bddef16b2f8862c1913e5a607d18fdc24b616af0ace55c63f41868d0a2414972", "shield": "417eeb707d0ac1b74e84ccd029024484f118985636727c5b3aab95e97f80fbab73", "reqs": "00", "rigging": "411c3436751e30e42043b29c4aa9f969d681b03c3273322a798aa68af152450124", "cargo": "00" } ]
Keys
A secp256r1 keypair is generated upon first use and stored PEM-encoded in~/.toda/secure/secp256r1and
~/.toda/secure/secp256r1.pubwith permissions of 0600. Flags will provide additional flexibility around multi-key and multi-signature key management.
Storage
Default storage for the CLI is the TODA flat-file disk backend, in~/.toda/store. This is suitable for development, however production services will require one of the indexed stores available from TODAQ.
Usage
$ toda COMMAND [--version, -v] [-i] [-h] [--out FILENAME] [--verbose] [--test] [--json] [--help]
Options to all CLI commands
-v, --version
Display the current version.
-i, --identity
Override the default identity file to use
-h, --human-readable
Display sizes in a human-readable format
-C [--list | --raw]
Display only the content of a packet as a hex string. `--list` will display the contents as a list of hashes, while `--raw` will display the raw bytes.
--config FILE_PATH
Path to a different config yaml file to use. Defaults to `~/.toda/config`
--out FILENAME
Specifies the output file path. Defaults to
~/.toda/store/HASH.toda`
--test
Dry Run. Doesn't create the file, just outputs raw bytes to the console
--json
Specifies the output format should be json
--help
Display the help text
--reset-defaults
Resets the config file to the default values
Commands
append
$ toda append [--prev PREV_TWIST] [--cargo CARGO_SOURCE | --empty] [CARGO_SRC|PREV_SRC]
Creates a new
*.todafile with the specified PREV and outputs the file bytes. Defaults to
~/.toda/store/HASH.toda.
eg.
$ toda append --prev 41fc9f5eb249400705724d97f2041a0e887f0ee5d9 --empty
create
$ toda create [--secp256r1 PUB_KEY_PATH] [--ed25519 PUB_KEY_PATH] [--rigging RIG_SPEC] [--shield SHIELD_SPEC] [--tether TETHER_HASH | --auto-tether] [--prev PREV_TWIST] [--line-server URL] {--cargo CARGO_SOURCE | --empty | CARGO_SOURCE}
Creates a new
*.todafile with the specified hashes and outputs the file bytes. Defaults to
~/.toda/store/HASH.toda. If you specify
--auto-tetherthe twist will have its tether set to the latest twist from the configured
lineServer(or the
--line-serverarg.)
eg.
$ toda create --tether 41015b9c3a0ff856f29358110b78c2189f65f60114 --empty
history
$ toda history FILE_SOURCE [--json] [--line] [--twist HASH]
Displays the details of this file and each of its PREV twists. If
--twistis specified then only show the history of that twist within this file. If
--lineis specified then show the complete history of the line containing this twist.
eg.
$ toda history <~/.toda/store/4110aa0c8260c64445e8a111190ee8a339776e86aa182b7aeeea492865b63a5dbc.toda twist 415359b8399d1cc0ecb8b10e1e989d134ef9175a0b5c70509a89eb2bfa8c755fda sats 00 prev 00 tether 00 shield 00 reqs SECP256r1 3059301306072a8648ce3d020106082a8648ce3d030107034200041203155587f8b14acf7e91d584e21aa41d0bb3551dacdc160c27dbd38901aa419c1ce39b0254aba580ba20ed4a56ebdff0ee6a9d8abc301afbd27a9c807db363 rigging 00 cargo 00 twist 4110aa0c8260c64445e8a111190ee8a339776e86aa182b7aeeea492865b63a5dbc sats SECP256r1 304402200e4b50eb910c4ece7946d1a0cf7b119718a57ef464a546ec8c16433a8971835602201f9badcc19c1edb93b0833da60fd201063de448d972ea39f65d0b5f2beb58d12 prev 415359b8399d1cc0ecb8b10e1e989d134ef9175a0b5c70509a89eb2bfa8c755fda tether 00 shield 00 reqs SECP256r1 3059301306072a8648ce3d020106082a8648ce3d030107034200041203155587f8b14acf7e91d584e21aa41d0bb3551dacdc160c27dbd38901aa419c1ce39b0254aba580ba20ed4a56ebdff0ee6a9d8abc301afbd27a9c807db363 rigging 00 cargo 00
$ toda history --json <~/.toda/store/4110aa0c8260c64445e8a111190ee8a339776e86aa182b7aeeea492865b63a5dbc.toda [ { "twist": "415359b8399d1cc0ecb8b10e1e989d134ef9175a0b5c70509a89eb2bfa8c755fda", "sats": "00", "prev": "00", "tether": "00", "shield": "00", "reqs": { "SECP256r1": "3059301306072a8648ce3d020106082a8648ce3d030107034200041203155587f8b14acf7e91d584e21aa41d0bb3551dacdc160c27dbd38901aa419c1ce39b0254aba580ba20ed4a56ebdff0ee6a9d8abc301afbd27a9c807db363" }, "rigging": "00", "cargo": "00" }, { "twist": "4110aa0c8260c64445e8a111190ee8a339776e86aa182b7aeeea492865b63a5dbc", "sats": { "SECP256r1": "304402200e4b50eb910c4ece7946d1a0cf7b119718a57ef464a546ec8c16433a8971835602201f9badcc19c1edb93b0833da60fd201063de448d972ea39f65d0b5f2beb58d12" }, "prev": "415359b8399d1cc0ecb8b10e1e989d134ef9175a0b5c70509a89eb2bfa8c755fda", "tether": "00", "shield": "00", "reqs": { "SECP256r1": "3059301306072a8648ce3d020106082a8648ce3d030107034200041203155587f8b14acf7e91d584e21aa41d0bb3551dacdc160c27dbd38901aa419c1ce39b0254aba580ba20ed4a56ebdff0ee6a9d8abc301afbd27a9c807db363" }, "rigging": "00", "cargo": "00" } ]
inspect
$ toda inspect HASH FILE_SOURCE [--json]
Displays the details of the packet associated with the specified hash in the file. Expands the reqs, sats and cargo tries by default. If --packet is specified will only display the top-level details of the packet.
eg.
$ toda inspect 41fe3edd4582ad9116a824776106659df3d055ce645f3389258f75200eaa58a25b <~/green_red_mix.toda body prev 00 tether 00 shield 00 reqs requirements weight 100 requirement SECP256r1 3059301306072a8648ce3d020106082a8648ce3d03010703420004d259092b977ef8718841ce1fcfa30fba2f2012f2f3b0d8b8ff5a2bacb4095f8be415696c6c9da371667b72538bb31e2fb39905ce3f2c1e69be8a64ec10fc91f8 weight 150 requirement SECP256r1 3059301306072a8648ce3d020106082a8648ce3d0301070342000429c2fe881e2f126eb0e2e9e2f6daf775957e99c31f5a1ac81f1de687e5ace3bb413c56bd30437ea8b552edc48192241d6ea0922ee8a3867c13750ce4185e1ce1 weight 200 requirement SECP256r1 3059301306072a8648ce3d020106082a8648ce3d03010703420004381dd109d3bdbd7eb8a2242ceafc7774cccd377eb26cd49764c2dd6783921939241b6363682a679e6629ef886d4bf36a8cbe25bcc3d36ae342bf243c6b5f9d73 rigging 00 cargo 00 sats 00
$ toda inspect 41fe3edd4582ad9116a824776106659df3d055ce645f3389258f75200eaa58a25b <~/green_red_mix.toda --json { "body": { "prev": "00", "tether": "00", "shield": "00", "reqs": { "requirements": [{ "weight": 100, "requirement": { "SECP256r1": "3059301306072a8648ce3d020106082a8648ce3d03010703420004d259092b977ef8718841ce1fcfa30fba2f2012f2f3b0d8b8ff5a2bacb4095f8be415696c6c9da371667b72538bb31e2fb39905ce3f2c1e69be8a64ec10fc91f8" } }, { "weight": 150, "requirement": { "SECP256r1": "3059301306072a8648ce3d020106082a8648ce3d0301070342000429c2fe881e2f126eb0e2e9e2f6daf775957e99c31f5a1ac81f1de687e5ace3bb413c56bd30437ea8b552edc48192241d6ea0922ee8a3867c13750ce4185e1ce1" } }, { "weight": 200, "requirement": { "SECP256r1": "3059301306072a8648ce3d020106082a8648ce3d03010703420004381dd109d3bdbd7eb8a2242ceafc7774cccd377eb26cd49764c2dd6783921939241b6363682a679e6629ef886d4bf36a8cbe25bcc3d36ae342bf243c6b5f9d73" } } ] }, "rigging": "00", "cargo": "00" }, "sats": "00" }
$ toda inspect --json --packet 4166278f9f242a9752255237a46117248f8f716ecc554735e40c3638474d8dc057 <~/.toda/store/41e6a26e2e37b721941cf450c96c95da2b91dbf9800faf50c6b3e660ab35078d9c.toda type Pair Trie Packet length 91872 content 41004da6b978acf8b17cdbe6baf7ef5c344c0ad503840665bb43a8918551ea5fee 416f349e24a69b7149a0f1f211a7800378f18f5085c61021f3ad3ed0d42a97d786 4100b15ce7d42877f0d861a1c44def21a2bb4f17336ae47d317734fd1e4614d4e1 4101a1d46d534c43e8cfbd12266d5c7bc6000b37b14cb4f545961187d78df106c2 41010da7af1c64ee241fbe21abff6bfbe2b41222c777daabdf4e591828ea17809e 412f9d3ca7f218221aec6eec33910e7c9a08cacf121d8e5832b0caeefef9bc365b 4101614f420c0eedd7cc586aeda7c11f9c2409a7eb293b86f94602f0d28b7431d9 41024b2518f40f6d028af922012968dfd465b3af0c494bd0c38468a0b53aa9c12b 41025d1e84cd7babce6322408515df1bc9c83f9faf960f42347e9cac965bd45bed 41762698a158430360c367aef9d7d9fd650d8e8eca6896e076043d2845b98fcd9b 4109bb088fe1a2a276dba9f8012afd7679b130643cea7ac0982118a488e1320287 415a7d59f442ccb93812edb651a5900cd9e18a068285cd8ab1d2dc6e79cd4c8260 410a698aa0695b79a015ba470e5e2254e043e1bbbc4148409d9bb559d05291ffce 416489c2e43b221739e833a9e1ae3bb73c7d2121c6549f23d3f6d967c1faab2162 410caf22673aca34f0a7efaae69c94261cb07ed91adfda3a6bdfd2e4b13ced290c 4116f092437c2ae06391e2105a439646ddff4ed0e411e5ff6d7d77583dc368a038 ... (and 166 more)
$ toda inspect --json --packet 411c3436751e30e42043b29c4aa9f969d681b03c3273322a798aa68af152450124 <~/.toda/store/41e6a26e2e37b721941cf450c96c95da2b91dbf9800faf50c6b3e660ab35078d9c.toda { type: 'Hash Packet', length: 99, content: [ '4123eb127b3caf920d3dd72f834b35b73e5b8bda870b0d7147838d182b5a9dd789', '410a5d17d3b19f82f8340d3977609aa9e86b4ad8b9bd71bd9eced9271f1d5b2e4a', '41d0b00c77c1f851ea4553a62e87f4c740357e1e6fe14b60dcabfbd3acf1d34018' ] }
list
$ toda list [--latest] [--all] [DIRECTORY|FILE_PATH]
Lists all twists found in
*.todafiles in the specified directory, or if a file is specified then lists only the twists in that file. Defaults to
~/.toda/source. If
--latestis specified will only show the most recent twists (or all if specified).
eg.
$ toda list 41403074e3b2c72cc00962aa87b614cdcb532ea2cb4841fd1a5afd33f80e0cc84c 4147699aee17b44e582d22f73047345fefd9b00ee298611f2d1d2e11cfcf19d1e8
hoist
$ toda hoist [--line-server URL] [--verify] FILE_SOURCE
Generates a hoist request for a twist to be posted to the line server. Defaults to the value of
lineServerin the
config.ymlIf `--verify` is specified, will return the value of the Hash associated with the hoist, or nothing if the hoist doesn't exist.
eg.
$ toda hoist --line-server http://line.todaq.net <~/.toda/store/41e6a26e2e37b721941cf450c96c95da2b91dbf9800faf50c6b3e660ab35078d9c.toda
get-hoist
$ toda get-hoist [--line-server URL] FILE_SOURCE
Returns the value of the Hash associated with the hoist, or nothing if the hoist doesn't exist. Defaults to the value of
lineServerin the
config.yml
eg.
$ toda get-hoist <~/.toda/store/411c3436751e30e42043b29c4aa9f969d681b03c3273322a798aa68af152450124.toda 410a3e68c6cf404b1e7be188f9b341651c4afc7ec6347fe0a8e85cf827cbe089bd
serve
$ toda serve [--web [--web-port PORT] [--inv-url URL]] [--inv [--inv-port PORT] [--inv-path DIRECTORY]]
Starts an inventory server and a web app to browse it. If no server is specified, both will be started. If web and inventory are using the same port one server will be started for both.
--webstarts the web server on the specified
--web-portor :3000.
--inv-urlindicates the URL for the inventory server to make requests.
--invstarts the inventory server on the specified
--inv-portor :3000.
--inv-pathindicates the directory on the server where files are stored.
eg.
$ toda serve Web && Inventory server running on http://localhost:3000
$ toda serve --web --web-port 8080 --inv-url http://localhost:3000 --inv Inventory server running on http://localhost:3000 Web server running on http://localhost:8080