-
Notifications
You must be signed in to change notification settings - Fork 171
proposal: cue repl
#356
Comments
@philipdexter I, for one, am a big fan of this proposal. Few questions:
This could be an identifier, like
I think this command is unnecessary assuming you allow expressions to be evaluated by default.
Just curious, is this a common idiom? Some possible other commands that come to mind:
I guess the latter could be done with "field" declarations. So without a command, an expression would evaluate, while an |
No, I think it's probably better to use either
Interestingly, this already works since
The repl currently works like: anything not starting with |
This is pretty cool if you haven't tried it! |
Both work for me. I had a 2 decade-streak of using Vi, so I'm inclined to go with
hah! Yes that is true. It is probably okay to just filter that error. We can do something more principled later.
Yeah, I think that is the case. I also think this is the expected behavior of REPLs.
That is the tricky design part. It probably makes sense to be consistent. So, say, to add something one would always have to start with Another idea is that to add one needs to do:
That is,
would set value
As the use of
would then mean "embed We probably also want to allow |
Isn't
Yeah, that looks nice. Probably could piggyback off the query syntax implementation there. Another thing to think about is supporting multiline statements. Perhaps ideally the repl could always detect when a statement is incomplete, and keep reading until it's completed. That hasn't been implemented yet though, so right now I've added a |
This issue has been migrated to cue-lang/cue#356. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Is your feature request related to a problem? Please describe.
From LISP to Python to Haskell, old and new languages alike have found that providing developers with a REPL greatly improves the relationship between the developer and the language runtime. CUE does not currently have a REPL, reducing the ease at which CUE beginners and experts alike interact with CUE.
Describe the solution you'd like
A CUE REPL :)
Describe alternatives you've considered
The current solution involves a text editor and a command line, constantly context switching between the two.
Additional context
Below is a proposal draft.
Repl proposal
Introduce
cue repl
.Some exploratory work has been done at https://github.com/philipdexter/cue.
An (out of date) example of it being used can be seen at https://asciinema.org/a/xgm2BpkyOVUNr5hjqaSOMKMT3
Use
Running
cue repl
within a module directory should start the repl with the module loaded.Running
cue repl
outside of a module will start the repl with a blank slate.The repl should have line editing features provided in common readline libraries.
Commands
Some initial command ideas could be
help
--print help text
l/lookup <path>
--print the value at <path>
h/history
--print history indexed by histnums
p/print
--print the current value
r/restore <histnum>
--restore the value at <histnum>
s/save <where>
--save the current value into <where>
Repl commands can be invoked by prefixing a
;
.For example the print command, which prints the current structure, can be invoked with
;p
or;print
.The text was updated successfully, but these errors were encountered: