Skip to content

Add WithInput to specify input stream #270

Closed

Description

@survivorbat

Is your feature request related to a problem? Please describe.

I'm a unit-test freak and I'm currently using the following construct to unit-test my cobra commands with huh:

err := form.WithProgramOptions(tea.WithInput(in), tea.WithOutput(out)).Run()

In which my tests will supply answers to the input stream based on the output received in the output stream. An answering machine, if you will.

Recently, form.WithOutput(out) was introduced which I'm grateful for, but I'd love to have an WithInput as well.

Describe the solution you'd like

I'd like WithInput(in io.Reader) to be added to the form objects to avoid having to use tea directly. Perhaps you could even introduce a piece of documentation on how to use it with 2 io.Pipe's to simulate user input based on questions in the output.

Describe alternatives you've considered

I'll keep using the above mentioned workaround.

Additional context

Related: #187

Activity

  1. changed the title [-]Add `WithInput` to specificy input stream[/-] [+]Add `WithInput` to specify input stream[/+] on Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions