Skip to content

testscript: Accept !cmd (without space) or provide better error #190

@awagner-iq

Description

@awagner-iq

A colleague is trying out testscript and used !cmd to call a custom command (note the lack of space). They got the error message "!cmd not defined" and where confused why the negation was not recognized. I'd like to improve that.

One option would be to accept the !cmd, parsing it as equivalent to ! cmd. This is easy to implement, but probably not backwards compatible.

Another option is to provide a better error message if a command is not found. e.g. if !cmd is looked up and not found, but cmd is, we could detect that and report "did you mean ! cmd?". Or - harder to implement, but more generally useful - we could search the defined commands by edit-distance to the missed command and if one of them is a close enough match, suggest that. x/tools has an internal package that might help.

I can send a PR, but wanted to discuss what option you prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions