jank icon indicating copy to clipboard operation
jank copied to clipboard

Add CLI REPL history persistence

Open jeaye opened this issue 1 year ago • 5 comments

We're using readline for the jank and native CLI REPLs. This gives us history within a session, but persisting that would be super helpful for iteration. Since we have two CLI REPLs, we should have two history files.

From what I can tell, the correct docs are here: https://tiswww.case.edu/php/chet/readline/history.html

If there's a more modern library for this, I'm open to us using that instead.


EDIT: LLVM has a LineEditor which uses libedit (Editline) behind the scenes. Example usage is here: https://github.com/llvm/llvm-project/blob/main/clang/tools/clang-repl/ClangRepl.cpp#L228-L232

If this works, we should stick with it. Otherwise, we can consider: https://github.com/antirez/linenoise

jeaye avatar Aug 16 '24 18:08 jeaye

I hate to be this guy, but it appears to me that there might be a licensing issue when using GNU readline in Jank. readline is GPL and in Jank's license file you state it's MPL2 and incompatible with secondary licenses. The MPL FAQ (https://www.mozilla.org/en-US/MPL/2.0/FAQ/) states in Q14 that you can't combine code in this case.

I might very well be wrong since I'm thankfully not a license expert. It's just something I noticed while browsing issues.

Some people like to use Editline (https://www.thrysoee.dk/editline/) as an alternative.

neoeleatic avatar Aug 31 '24 10:08 neoeleatic

The MPL v2 is GPL compatible provided the software is dual-licensed.

raoulmillais avatar Sep 07 '24 13:09 raoulmillais

I hate to be this guy, but it appears to me that there might be a licensing issue when using GNU readline in Jank. readline is GPL and in Jank's license file you state it's MPL2 and incompatible with secondary licenses. The MPL FAQ (https://www.mozilla.org/en-US/MPL/2.0/FAQ/) states in Q14 that you can't combine code in this case.

I might very well be wrong since I'm thankfully not a license expert. It's just something I noticed while browsing issues.

Some people like to use Editline (https://www.thrysoee.dk/editline/) as an alternative.

Super cool of you to call this out! Nothing to hate. Rather than changing any licensing, we can replace readline for a more flexibly licensed alternative. Thanks, also, for pointing out Editline.

I believe that LLVM has line editing functionality and we're already embedding it, so I think it makes sense to move in that direction first.

jeaye avatar Oct 03 '24 05:10 jeaye

@jeaye what do you mean by two CLIs and two history files? all i see is the jank CLI

ValorZard avatar Oct 09 '24 17:10 ValorZard

We have a cpp-repl command and a repl command. The former takes in C++ code, the later takes in jank code. We can actually skip the cpp-repl command now and just do the repl command.

On October 9, 2024 10:32:26 AM PDT, Srayan Jana @.***> wrote:

@jeaye what do you mean by two CLIs and two history files? all i see is the jank CLI

-- Reply to this email directly or view it on GitHub: https://github.com/jank-lang/jank/issues/85#issuecomment-2402904717 You are receiving this because you were mentioned.

Message ID: @.***>

jeaye avatar Oct 09 '24 18:10 jeaye

This is closed by #125. We now use libedit, as wrapped by LLVM.

jeaye avatar Nov 22 '24 20:11 jeaye