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

Open
IanButterworth opened this issue Mar 23, 2024 · 0 comments
Open

Detect and tip when prompt is entered erroneously #427

IanButterworth opened this issue Mar 23, 2024 · 0 comments

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

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

1 participant