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

Improve command input recognition #805

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Improve command input recognition #805

wants to merge 4 commits into from

Commits on Dec 13, 2023

  1. Improve command input recognition

    Currently, we simply split the input on whitespace and use the first
    word as the command name to check if it's a command. But this means that
    assigning a local variable which's name is the same as a command will
    also be recognized as a command.
    
    For example, in the following case, `info` is recognized as a command:
    
    ```
    irb(main):001> info = 123
    `debug` command is only available when IRB is started with binding.irb
    => nil
    ```
    
    This commit improves the command input recognition by using more sophis-
    ticated regular expressions.
    st0012 committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    b7815ac View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    85c37c4 View commit details
    Browse the repository at this point in the history
  3. Raise a warning if the input causes an error and partially matches a …

    …command
    
    As we now proceed to stricter syntax checking for commands, incorrect
    command input would be processed as Ruby instead and likely causes
    errors. In that case, we should raise a warning to the user.
    
    For example, if an input is `show_source Foo bar`, the user would see
    a warning about the possible syntax error for using `show_source` command.
    
    But with this approach, we also need add a condition for the `measure`
    command as it's actually used as a method call with block.
    st0012 committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    218f22b View commit details
    Browse the repository at this point in the history
  4. Address feedback

    st0012 committed Dec 13, 2023
    Configuration menu
    Copy the full SHA
    e02f06e View commit details
    Browse the repository at this point in the history