Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replay interactive REPL menus? #71

Open
gdalle opened this issue Jul 6, 2023 · 3 comments
Open

Replay interactive REPL menus? #71

gdalle opened this issue Jul 6, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@gdalle
Copy link

gdalle commented Jul 6, 2023

Hi there, thanks for the awesome package!
I'm writing a blog post on Julia workflows, and I want to demonstrate the use of packages like Cthulhu, PkgTemplates and others which have interactive terminal menus.
Is that something Replay can help with? Or does it only work with plain REPL prompts?

@terasakisatoshi
Copy link
Member

Hello, @gdalle

My apologies for the delay.

I'm writing a blog post on Julia workflows, and I want to demonstrate the use of packages like Cthulhu, PkgTemplates and others which have interactive terminal menus.

This is cool 👍. If your instruction is self-contained within Julia REPL, Replay.jl can help you. For example here I used Replay.jl to show how to use Debugger.jl

https://github.com/AtelierArith/julia_tutorial/blob/main/demos/06_debugger/script.jl

$ cd /path/to/06_debugger/script.jl
$ julia --project=@. -e 'using Pkg; Pkg.instantiate()'
$ julia --project=@. script.jl
2023-09-06.0.35.57.mov

The following example shows how to use Revise.jl. Have a try 🚀

https://github.com/AtelierArith/julia_tutorial/blob/main/demos/05_revise/script.jl

@terasakisatoshi
Copy link
Member

Although this is not a beautiful solution (especially CTRL_M), it works.

using Replay

UP_ARROW = "\e[A"
DOWN_ARROW = "\e[B"
CTRL_M = "\x0D"

instructions = [
    "using REPL.TerminalMenus",
    """
    options = ["apple", "orange", "grape", "strawberry",
                "blueberry", "peach", "lemon", "lime"];
    """,
    "menu = RadioMenu(options, pagesize=4);",
    """
    choice = request("Choose your favorite fruit:", menu)
    """,
    "$(DOWN_ARROW)$(DOWN_ARROW)$(CTRL_M)",
]

replay(instructions)

@gdalle
Copy link
Author

gdalle commented Sep 6, 2023

Thanks for the answer! I'll see where I can incorporate this

@hyrodium hyrodium assigned hyrodium and unassigned hyrodium Oct 20, 2023
@hyrodium hyrodium added the documentation Improvements or additions to documentation label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants