Skip to content

Commit

Permalink
feat: Iroh console (REPL) and restructured CLI (#1356)
Browse files Browse the repository at this point in the history
## Description

This adds a REPL to the main `iroh` binary. It builds upon #1216.


* The REPL embeds all commands that operate via the RPC client - which,
currently, is everything but `provide` (which should be called `start`),
`get` and `doctor`.

* The REPL has two new, REPL-only commands: `set-doc` and `set-author`.
`set-doc` changes the state of the REPL: author and document will be
displayed above the input line, and the document commands (`set`, `get`,
`list` , `share` etc) will be available top-level.

* Most of the changes in `src/commands.rs` only move code and the
`rpc_port` option around, the individual commands are not changed in
this PR.

## Notes & open questions

* The document and author IDs in the `list` commands are currently
printed in hex. Should change to base32.

* I'm not yet super sure about the `set-doc` and `set-author` commands.
Another path might be to dig more into a pwd-like structure and have a
`cd` command or so. This could then also move further into documents.
I'm not sure how the author fits in here.

* When in the level of a document, there's a conflict between the `doc
list` command (which is just `list` then) and the top-level `list`
command (to list blobs and collections). Not sure yet what the solution
is. For now I embedded only the `sync` commands on the doc level, but I
think I'd prefer to have the global set of commands not change between
levels. Maybe we just rename the top-level `list` command to `blobs` and
group the other blob-related commands (`add', a tbd `get` via RPC,
possibly `export`) there.

* The REPL embeds all the existing RPC CLI commands. For this I changed
the structure of the `src/cli/commands.rs` to a) split between
`RpcCommands` and `FullCommands` , the latter are the ones that start an
actual iroh node (plus doctor, wasn't sure about that for now). The
former all work atop the RPC client. For them to not create a new RPC
client for each REPL command, I moved the `--rpc-port` option to the top
level. This is not super correct, because it does not apply to
`provide`, `get`, `doctor`. Clap does not allow to scope an argument to
a set of subcommands by default, see [this
discussion](clap-rs/clap#5070 (comment)).
Still thinking about what the cleanest solution is.

## Change checklist

- [ ] Self-review.
- [ ] Documentation updates if relevant.
- [ ] Tests if relevant.

---------

Co-authored-by: dignifiedquire <me@dignifiedquire.com>
Co-authored-by: Asmir Avdicevic <asmir.avdicevic64@gmail.com>
Co-authored-by: Kasey <klhuizinga@gmail.com>
Co-authored-by: Brendan O'Brien <sparkle_pony_2000@qri.io>
  • Loading branch information
5 people authored Aug 24, 2023
1 parent 0503244 commit 581adf7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 581adf7

Please sign in to comment.