Skip to content

Support command prefixes in REPL #8901

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

Merged
merged 3 commits into from
May 8, 2020
Merged

Conversation

cb372
Copy link
Contributor

@cb372 cb372 commented May 7, 2020

e.g. :q or :qu instead of :quit.

If exactly one command matching the prefix is found, it is executed.

If multiple matching commands are found, an error is shown. (Currently this is not possible, as each command starts with a different letter.)

I've tested manually but couldn't find any automated tests for the REPL. Happy to write a test if someone can point me to the right place. Added a scripted test.

e.g. `:q` or `:qu` instead of `:quit`.

If exactly one command matching the prefix is found, it is executed.

If multiple matching commands are found, an error is shown. (Currently
this is not possible, as each command starts with a different letter.)
Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

@smarter
Copy link
Member

smarter commented May 7, 2020

I've tested manually but couldn't find any automated tests for the REPL.

They're in https://github.com/lampepfl/dotty/tree/master/compiler/test/dotty/tools/repl

@smarter
Copy link
Member

smarter commented May 7, 2020

There's also scripted repl tests in https://github.com/lampepfl/dotty/tree/master/compiler/test-resources

@iamrecursion
Copy link
Contributor

This closes #115 in the feature requests repl.

matchingParsers match {
case Nil => UnknownCommand(cmd)
case f :: Nil => f(arg)
case _ => AmbiguousCommand(cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pass the list of matching commands here to make the error message more descriptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Fixed.

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

Successfully merging this pull request may close these issues.

4 participants