Project URL: Glitch :・゚✧
In particular, doOtPull
et al. in src/index.js
.
(permalink to this version: snail-cli/index.js at v1.4.0 · wh0/snail-cli · GitHub)
The “OT” service is the part of Glitch that the web editor connects to, meaning:
- It can handle the “multiplayer” case where multiple collaborators type at the same time.
- Users on the real web editor can see changes immediately without you having to run
refresh
. - You can use it to look at public projects without being a collaborator.
- It’s suitable for dealing with few, smallish text files.
I’ve written up a collection of command line tools: push
and pull
(kind of like adb
's) and mv
, rm
, and ls
(kind of like coreutils
's).
These tools don’t connect for a significant length of time and work interactively; they instead take a quick look to find the file they need, send the change, and exit. As a result, the code is simplified in that it doesn’t have the logic to watch for changes and resolve merge conflicts, and its notion of correctness is only to the level of “it should do the right thing if nothing else is going on.”
Bonus note: some fancier safeguards from the web editor aren’t replicated, such making sure you’re not trying to move a directory into a subdirectory inside itself.