Skip to content

[WIP] Fix #3007: Added silencing of the output in initial and cleanup commands #4933

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

Conversation

SzymonPajzert
Copy link
Contributor

Implementing the feature requested in #3007 by dropping the output of the executed commands.

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! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@SzymonPajzert SzymonPajzert changed the title Added silencing of the output in initial and cleanup commands [WIP] Fix #3007Added silencing of the output in initial and cleanup commands Aug 12, 2018
@SzymonPajzert SzymonPajzert changed the title [WIP] Fix #3007Added silencing of the output in initial and cleanup commands [WIP] Fix #3007: Added silencing of the output in initial and cleanup commands Aug 12, 2018
@allanrenucci
Copy link
Contributor

Thanks @SzymonPajzert. I'll take a look when I'm back from vacation

@allanrenucci allanrenucci self-assigned this Aug 13, 2018
@allanrenucci
Copy link
Contributor

I think this is the right approach to implement a silent mode for the REPL. However, the issue description was erroneous and initialCommands and cleanupCommands should not be interpreted in a silent mode (see #3007 (comment)).

The silent mode could be useful to implement value bindings. I would implement everything in ConsoleInterface. Something along the line of:

val driver = new ReplDriver(completeArgs, classLoader = Some(loader))
val initState = driver.initState
val s0 = (bindNames, bindValues).zipped.folLeft(initState) {
  case (state, (name, value)) => driver.bind(name, value)(state)
}
val s1 = driver.run(initialCommands)(s0)
// handle failure during initialisation
val s2 = driver.runUntilQuit(s1)
driver.run(s1)

Value bindings can be implemented in a different PR


val s0 = driver.bindValues((bindNames, bindValues).zipped)
val s1 = driver.run(initialCommands)(s0)
// TODO handle failure during initialisation
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to open issues for this and value bindings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created #5069 to implement the bindings, but I don't understand how failure during initialization should be signaled. Should we mark it with some checked exception?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes the current API that returns a state is not ideal. Let's not worry about it here, it can be fixed in a separate PR

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM. Please squash your commits

@SzymonPajzert SzymonPajzert force-pushed the wip/silencing-output-i3007 branch from 9f1c3dd to a315ec3 Compare September 2, 2018 14:20
@SzymonPajzert
Copy link
Contributor Author

Is there any linter available to not submit changes with nitpicks?

@allanrenucci
Copy link
Contributor

allanrenucci commented Sep 2, 2018

Is there any linter available to not submit changes with nitpicks?

No. At some point we talked about using scalafmt, but we decided not to enforce a specific style

One last think before we merge (sorry I didn't spot it earlier). Can you update the commit message to not mention silencing anymore. Something like: Fix #3007: Add support for initial and cleanup command in the REPL

@SzymonPajzert SzymonPajzert force-pushed the wip/silencing-output-i3007 branch from a315ec3 to aefd7cf Compare September 2, 2018 15:06
@allanrenucci allanrenucci merged commit a31ea22 into scala:master Sep 2, 2018
@allanrenucci
Copy link
Contributor

Thanks @SzymonPajzert! 🎉

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.

3 participants