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

Detect and tip when prompt is entered erroneously #427

Closed
IanButterworth opened this issue Mar 23, 2024 · 1 comment
Closed

Detect and tip when prompt is entered erroneously #427

IanButterworth opened this issue Mar 23, 2024 · 1 comment

Comments

@IanButterworth
Copy link
Sponsor Member

julia> pkg> add Foo
ERROR: ParseError:
# Error @ REPL[3]:1:9
pkg> add Foo
#       └──┘ ── extra tokens after end of expression
Stacktrace:
 [1] top-level scope
   @ REPL:1

It'd be good if in this case we gave a tip.

This isn't the right approach, but some abandoned code from a cruder example had some suggested language.

function check_for_prompt_start(line::String)
    if startswith(line, JULIA_PROMPT)
        printstyled("Tip:"; color=info_color())
        println(" No need to type `$JULIA_PROMPT`; enter your commands directly.")
    elseif startswith(line, PKG_PROMPT)
        printstyled("Tip:"; color=info_color())
        println(" To switch to the `$PKG_PROMPT` prompt, press `]` rather than typing `$PKG_PROMPT`.")
    elseif startswith(line, SHELL_PROMPT)
        printstyled("Tip:"; color=info_color())
        println(" To switch to the `$SHELL_PROMPT` prompt, press `;` rather than typing `$SHELL_PROMPT`.")
    elseif startswith(line, HELP_PROMPT)
        printstyled("Tip:"; color=info_color())
        println(" To switch to the `$HELP_PROMPT` prompt, press `?` rather than typing `$HELP_PROMPT`.")
    end
end

Idea proposed in JuliaLang/julia#53823

@c42f
Copy link
Member

c42f commented Aug 6, 2024

Good idea! As people said in JuliaLang/julia#53823 I think this is a REPL thing not a parser thing so I'll close this one here :)

@c42f c42f closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants