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

Add {Input,Output}Stream support #157

Merged
merged 1 commit into from
Apr 8, 2020
Merged

Add {Input,Output}Stream support #157

merged 1 commit into from
Apr 8, 2020

Conversation

michaelbull
Copy link
Contributor

This change adds support for InputStream and OutputStream options:

    private val input by option().inputStream().defaultStdin()
    private val output by option().outputStream().defaultStdout()

The option uses the FILE metavar and uses the Path completion candidates.

As is the common convention of many command-line tools, passing a hyphen (-) will serve as a substitute for stdin/stdout.

The sample demonstrates a reimplementation of the common md5sum utility:

$ echo 'hello world' > input.txt
$ cat input.txt | ./runsample stream
  md5sum: d41d8cd98f00b204e9800998ecf8427e

@ajalt ajalt merged commit a3b8903 into ajalt:master Apr 8, 2020
@ajalt
Copy link
Owner

ajalt commented Apr 8, 2020

Great idea!

@michaelbull
Copy link
Contributor Author

Thanks @ajalt. When should we expect the next release? I'd like to start adopting this in my codebases.

@ajalt
Copy link
Owner

ajalt commented Apr 8, 2020

I don't have a release timeline, but you can use the snapshot build from sonatype or jitpack in the meantime. That would also be helpful so that you could test it out prior to release.

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.

2 participants