Closed jennybc closed 1 year ago
I found a solution I like to the infinite loop problem, which is to append "0"
to any mocked user input. And this retains the ability to provide multiple inputs.
The original intent was to be able to supply multiple values that were used in turn.
I also added a test for this behaviour.
This is functionally important for gargle, because
cli_menu()
is ultimately implemented on top ofreadline()
, notutils::menu()
. And Jupyter has shimmedreadline()
to work even though, at the time of writing,base::interactive()
returnsFALSE
in Jupyter.Therefore this PR makes gargle's interactive choices work in Jupyter notebooks, which notably covers Google Colab.
This is part (but not all) of making user auth "just work" on Colab (#140).
I have adapted
cli_menu()
from https://github.com/rstudio/rsconnect/blob/main/R/utils-cli.R. I think most of my changes might be generally positive and could be considered when/if something like this goes into cli itself (https://github.com/r-lib/cli/issues/228). I also added tests.@hadley @gaborcsardi I don't really need feedback on this (though it's welcome). This is more of an FYI request for review, to continue the discussion around https://github.com/r-lib/cli/issues/228. I'll make a few comments inline.
Links to the Jupyter +
readline()
story:https://github.com/IRkernel/IRkernel/pull/452
https://github.com/IRkernel/IRkernel/blob/1eddb304b246c14b62949abd946e8d4ca5080d25/R/execution.r#L131-L137
https://github.com/IRkernel/IRkernel/blob/1eddb304b246c14b62949abd946e8d4ca5080d25/R/execution.r#L271-272