textileio / go-threads

Server-less p2p database built on libp2p
MIT License
452 stars 65 forks source link

Threads REPL #239

Open sanderpick opened 4 years ago

sanderpick commented 4 years ago

cc @andrewxhill @eightysteele

I know you guys were chatting about the shell and what it might be able to do. @jsign and I also chatted about this during the heavy threads development. It would be so nice to have a real, mongo feeling REPL interface.

This means we'll need some kind of scripting language since we probably don't want to reinvent the wheel in terms of parsing the input. I wonder, could we use a JavaScript interpreter? Again, inspired my mongo.

Some possible ways forward:

A Go program with a JS interpreter (written in Go)

This would involve interpreting the user input as JS, which would somehow map to an input compatible with the threads Go client. mongo takes a similar approach, apparently using SpiderMonkey: https://stackoverflow.com/a/8331139/641834

Other interpreters:

Pros: All the niceties that come with standalone binary

A NodeJS program

This would involve using the built in REPL (https://nodejs.org/api/repl.html) alongside the threads JS client. Everything should be available there, from creating stores to starting transactions.

Pros: Likely much faster development time, npm install-able

Thoughts?

carsonfarmer commented 4 years ago

I would vote for a nodejs program, which shouldn’t come as a surprise 😜. This is potentially much more hackable for outside devs, easy to install / setup, and the faster turnaround time might be worth it right there? It I also don’t really have a horse 🐎 in this race at the moment, so take my vote with a grain of salt 🧂.

eightysteele commented 4 years ago

@sanderpick @carsonfarmer +1 for a real-mongo-feeling REPL interface. bullish on the proposal here for a nodejs program (vs. standalone binary)—fast dev time with npm install is pretty great imo. pumped!

sanderpick commented 4 years ago

Sounds good to me! The NodeJS REPL looks really easy to use. You just export functions and they magically are available to the user by name: https://nodejs.org/en/knowledge/REPL/how-to-create-a-custom-repl/

eightysteele commented 4 years ago

sick! reading up on the custom repl stuff now.

eightysteele commented 4 years ago

here's a stab—probably a lot of things to change/evolve, but this at least gets something going: https://github.com/eightysteele/thread-shell