AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.09k stars 352 forks source link

Print two spaces between the prompts and the responses #299

Open waldyrious opened 4 years ago

waldyrious commented 4 years ago

Reporting an issue first raised downstream at https://github.com/cli/cli/issues/1912 (that's why I'm reusing this structured format and why the examples are about using the gh tool):

Description of the problem

After an interactive usage session (e.g. doing gh pr create), the result has the prompts and their responses separated with a single space, which is readable in the command line with bold text and colors, but makes it hard to discern the structure of the session when it's reproduced in a plaintext environment (e.g. when quoting it elsewhere, as I do below.)

Proposed solution

Simply printing two spaces between the prompts and their responses would allow for a visual separation in plaintext mode, and would not negatively affect the console output.

Additional context

Here's an example session for gh pr create:

$ gh pr create

Creating pull request for my-branch-name into master in foo/bar

? Title Lorem ipsum dolor sit amet
? Body <Received>
? What's next? Add metadata
? What would you like to add? Reviewers
? Reviewers johndoe
? What's next? Submit
https://github.com/foo/bar/pull/123

And here's how it would look with two spaces after the prompts:

$ gh pr create

Creating pull request for my-branch-name into master in foo/bar

? Title  Lorem ipsum dolor sit amet
? Body  <Received>
? What's next?  Add metadata
? What would you like to add?  Reviewers
? Reviewers  johndoe
? What's next?  Submit
https://github.com/foo/bar/pull/123
AlecAivazis commented 4 years ago

Hey @waldyrious! Thanks for forwarding this upstream.

I definitely see the appeal. I think the next question is whether this constitutes an break in the API. I think the only situation it really breaks is if someone is checking for the exact prompt contents which they have to accept is brittle for this exact reason. I think I am okay sneaking this into v2.

waldyrious commented 4 years ago

Great! I too fail to see how this would be breaking for non-contrived cases.

(Thanks for the fast response btw.)