Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BurntSushi/tabwriter
Elastic tabstops for Rust.
https://github.com/BurntSushi/tabwriter
Last synced: about 2 months ago
JSON representation
Elastic tabstops for Rust.
- Host: GitHub
- URL: https://github.com/BurntSushi/tabwriter
- Owner: BurntSushi
- License: unlicense
- Created: 2014-09-07T23:49:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-27T14:39:25.000Z (6 months ago)
- Last Synced: 2024-04-01T09:47:26.711Z (3 months ago)
- Language: Rust
- Size: 89.8 KB
- Stars: 242
- Watchers: 9
- Forks: 26
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: COPYING
Lists
- awesome-rust - BurntSushi/tabwriter
- awesome-rust-zh - BurntSushi/tabwriter - 弹性 tab 位(即,文本列对齐)[<img src="https://api.travis-ci.org/BurntSushi/tabwriter.svg?branch=master">](https://travis-ci.org/BurntSushi/tabwriter) (库 / 文本处理)
- awesome-rust - BurntSushi/tabwriter - ci.org/BurntSushi/tabwriter.svg?branch=master)](https://travis-ci.org/BurntSushi/tabwriter) (Libraries / Text processing)
- awesome-stars - BurntSushi/tabwriter - Elastic tabstops for Rust. (Rust)
- awesome-rust - BurntSushi/tabwriter - ci.org/BurntSushi/tabwriter.svg?branch=master">](https://travis-ci.org/BurntSushi/tabwriter) (Libraries / Text processing)
- awesome-stars - tabwriter
- awesome-rust-cn - BurntSushi/tabwriter - ci.org/BurntSushi/tabwriter.svg?branch=master">](https://travis-ci.org/BurntSushi/tabwriter) (Libraries / Text processing)
- awesome-rust - BurntSushi/tabwriter - ci.org/BurntSushi/tabwriter.svg?branch=master">](https://travis-ci.org/BurntSushi/tabwriter) (库 Libraries / 文本处理 Text processing)
- awesome-rust-cn - BurntSushi/tabwriter
- awesome-rust - BurntSushi/tabwriter - ci.org/BurntSushi/tabwriter.svg?branch=master">](https://travis-ci.org/BurntSushi/tabwriter) (Libraries / Text processing)
- awesome-rust - BurntSushi/tabwriter - ci.org/BurntSushi/tabwriter.svg?branch=master)](https://travis-ci.org/BurntSushi/tabwriter) (Libraries / Text processing)
README
tabwriter is a crate that implements
[elastic tabstops](http://nickgravgaard.com/elastictabstops/index.html). It
provides both a library for wrapping Rust `Writer`s and a small program that
exposes the same functionality at the command line.[![Build status](https://github.com/BurntSushi/tabwriter/workflows/ci/badge.svg)](https://github.com/BurntSushi/tabwriter/actions)
[![](http://meritbadge.herokuapp.com/tabwriter)](https://crates.io/crates/tabwriter)Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org).
### Simple example of library
```rust
use std::io::Write;use tabwriter::TabWriter;
let mut tw = TabWriter::new(vec![]);
tw.write_all(b"
Bruce Springsteen\tBorn to Run
Bob Seger\tNight Moves
Metallica\tBlack
The Boss\tDarkness on the Edge of Town
").unwrap();
tw.flush().unwrap();let written = String::from_utf8(tw.into_inner().unwrap()).unwrap();
assert_eq!(&written, "
Bruce Springsteen Born to Run
Bob Seger Night Moves
Metallica Black
The Boss Darkness on the Edge of Town
");
```You can see an example of *real* use in my
[CSV toolkit](https://github.com/BurntSushi/xsv/blob/master/src/cmd/table.rs#L57-L60).### Simple example of command line utility
```bash
[andrew@Liger tabwriter] cat sample | sed 's/ /\\t/g'
a\tb\tc
abc\tmnopqrstuv\txyz
abcmnoxyz\tmore texta\tb\tc
[andrew@Liger tabwriter] ./target/tabwriter < sample
a b c
abc mnopqrstuv xyz
abcmnoxyz more texta b c
```Notice that once a column block is broken, alignment starts over again.
### Documentation
The API is fully documented with some examples:
[http://burntsushi.net/rustdoc/tabwriter/](http://burntsushi.net/rustdoc/tabwriter/).### Installation
This crate works with Cargo. Assuming you have Rust and
[Cargo](http://crates.io/) installed, simply check out the source and run
tests:```bash
git clone git://github.com/BurntSushi/tabwriter
cd tabwriter
cargo test
```You can also add `tabwriter` as a dependency to your project's `Cargo.toml`:
```toml
[dependencies]
tabwriter = "1"
```### Dealing with ANSI escape codes
If you want `tabwriter` to be aware of ANSI escape codes, then you should
enable the `TabWriter::ansi` option. Previously this was done by enabling the
crate feature `ansi_formatting`, but that feature is now deprecated. (If you
use it, then `TabWriter::ansi` will be automatically enabled for you. Otherwise
it is disabled by default.)### Minimum Rust version policy
This crate's minimum supported `rustc` version is `1.67.0`.
The current policy is that the minimum Rust version required to use this crate
can be increased in minor version updates. For example, if `crate 1.0` requires
Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also require Rust
1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a newer minimum
version of Rust.In general, this crate will be conservative with respect to the minimum
supported version of Rust.