Skip to content

Detect and tip when prompt is entered erroneously #427

@IanButterworth

Description

@IanButterworth
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions