stdio
Version, currently 0.1.25 versions
- 0.1.4latestJul 23, 2017
- 0.1.3not indexedMay 13, 2021
- 0.1.2not indexedMay 13, 2021
- 0.1.1not indexedMay 13, 2021
- 0.1.0not indexedMay 13, 2021
github.com/mosop/stdio
A small Crystal library for capturing standard I/O streams.
8 stars
5 dependents
License: MIT
Nothing has been indexed for 0.1.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
stdio:
github: mosop/stdio
version: ~> 0.1.2Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.2. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# Crystal Stdio
A small Crystal library for capturing standard I/O streams.
[](https://travis-ci.org/mosop/stdio)
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
stdio:
github: mosop/stdio
```
## Usage
```crystal
require "stdio"
out, err, in = Stdio.capture do |io|
STDOUT.puts ":)"
STDERR.puts ":("
io.in.puts ":P"
[io.out.gets, io.err.gets, STDIN.gets]
end
puts out # prints ":)"
puts err # prints ":("
puts in # prints ":P"
```
## Decapturing
The `out` and `err` methods return *decapturing* I/Os. The type of the I/O means that the I/O is not capturing the standard I/O any more. In other words, you can not capture the decaptured standard I/O again in the same yielded block after calling `out` or `err`.
```crystal
Stdio.capture do |io|
STDOUT.puts ":)" # captured
io.out.gets # decaptured and taken ":)\n"
STDOUT.puts ":X" # ":X" is printed, not captured
end
```
Why is decapturing needed? Because a process easily hangs up when you send any waiting methods to I/Os that are still capturing the standard I/Os.
To read I/Os keeping capturing and control waiting by yourself, use the `out!` and `err!` methods.
```crystal
Stdio.capture do |io|
STDOUT.puts ":)"
io.out!.gets # => ":)\n"
STDOUT.puts ":X"
io.out!.gets # => ":X\n"
io.out!.gets # waits
end
```
## Release Notes
* v0.1.3
* Capture#out!, Capture#err!
* v0.1.2
* STDIN
## Contributing
1. Fork it ( https://github.com/mosop/stdio/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [mosop](https://github.com/mosop) - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- May 13, 2021
- Commit
b48b66c2e79d- Indexed
- not yet
Dependents
Repository
github.com/mosop/stdio
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 5