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

Custom interactive prompts #1021

Merged
merged 12 commits into from Dec 17, 2013
Merged

Conversation

davidhalter
Copy link

improves and fixes #741. might fix #177 (not sure though) and probably also helps with #7 (also I don't know if that one is really fully solvable).

There's an implementation difference. The env variable is not named prompt_responses anymore but prompts, because I think it's shorter and a better fit.

For the future we could think about two things:

  • Currently the dictionary allows only for strings, I think it would be interesting to allow compiled regex objects, should not be hard to implement.
  • @owenn used a small hack to make a prompt react once (and not twice on the same input). This involves removing the old matching output. That means the output of run() doesn't contain the complete text. That's not extremely bad, but we could improve this by counting bytes (and just not trying to check for a new prompt if the number of bytes doesn't change). But I don't really know what side effects that would have, since it's also possible to just answer prompts manually (and use the backward button).

And also I would like to see tox in fabric. It makes testing (especially the setting up part) way easier (if you haven't heard of it: it eases testing against multiple python versions).

Now you can do something like:

with settings(prompts={"remove write-protected regular file `/etc/fuse.conf'? ": "yes"}):
    run('rm -i /etc/fuse.conf')

Not that this example makes sense, but it shows the use case well: interactive prompts.

When could we expect a release containing that code?

@akitada
Copy link

akitada commented Dec 16, 2013

+1
This worked great.

@bitprophet
Copy link
Member

Was leery about this originally, but the changes this makes to core (aka the bits in io.py) look pretty light, so I will try to play around with it briefly and get it in for the next feature release (~1 week out). Thanks! also @akitada for the prod :)

bitprophet added a commit that referenced this pull request Dec 17, 2013
bitprophet added a commit that referenced this pull request Dec 17, 2013
bitprophet added a commit that referenced this pull request Dec 17, 2013
@bitprophet bitprophet merged commit 0cb6020 into fabric:master Dec 17, 2013
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.

None yet

4 participants