Debian Codegraph @

README.md

raw symbols SCIP
1 tabwriter is a crate that implements
2 [elastic tabstops](http://nickgravgaard.com/elastictabstops/index.html). It
3 provides both a library for wrapping Rust `Writer`s and a small program that
4 exposes the same functionality at the command line.
5
6 [![Build status](https://github.com/BurntSushi/tabwriter/workflows/ci/badge.svg)](https://github.com/BurntSushi/tabwriter/actions)
7 [![](http://meritbadge.herokuapp.com/tabwriter)](https://crates.io/crates/tabwriter)
8
9 Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org).
10
11
12 ### Simple example of library
13
14 ```rust
15 use std::io::Write;
16
17 use tabwriter::TabWriter;
18
19 let mut tw = TabWriter::new(vec![]);
20 tw.write_all(b"
21 Bruce Springsteen\tBorn to Run
22 Bob Seger\tNight Moves
23 Metallica\tBlack
24 The Boss\tDarkness on the Edge of Town
25 ").unwrap();
26 tw.flush().unwrap();
27
28 let written = String::from_utf8(tw.into_inner().unwrap()).unwrap();
29
30 assert_eq!(&written, "
31 Bruce Springsteen Born to Run
32 Bob Seger Night Moves
33 Metallica Black
34 The Boss Darkness on the Edge of Town
35 ");
36 ```
37
38 You can see an example of *real* use in my
39 [CSV toolkit](https://github.com/BurntSushi/xsv/blob/master/src/cmd/table.rs#L57-L60).
40
41
42 ### Simple example of command line utility
43
44 ```bash
45 [andrew@Liger tabwriter] cat sample | sed 's/ /\\t/g'
46 a\tb\tc
47 abc\tmnopqrstuv\txyz
48 abcmnoxyz\tmore text
49
50 a\tb\tc
51 [andrew@Liger tabwriter] ./target/tabwriter < sample
52 a b c
53 abc mnopqrstuv xyz
54 abcmnoxyz more text
55
56 a b c
57 ```
58
59 Notice that once a column block is broken, alignment starts over again.
60
61
62 ### Documentation
63
64 The API is fully documented with some examples:
65 [http://burntsushi.net/rustdoc/tabwriter/](http://burntsushi.net/rustdoc/tabwriter/).
66
67
68 ### Installation
69
70 This crate works with Cargo. Assuming you have Rust and
71 [Cargo](http://crates.io/) installed, simply check out the source and run
72 tests:
73
74 ```bash
75 git clone git://github.com/BurntSushi/tabwriter
76 cd tabwriter
77 cargo test
78 ```
79
80 You can also add `tabwriter` as a dependency to your project's `Cargo.toml`:
81
82 ```toml
83 [dependencies]
84 tabwriter = "1"
85 ```
86
87
88 ### Dealing with ANSI escape codes
89
90 If you want `tabwriter` to be aware of ANSI escape codes, then you should
91 enable the `TabWriter::ansi` option. Previously this was done by enabling the
92 crate feature `ansi_formatting`, but that feature is now deprecated. (If you
93 use it, then `TabWriter::ansi` will be automatically enabled for you. Otherwise
94 it is disabled by default.)
95
96
97 ### Minimum Rust version policy
98
99 This crate's minimum supported `rustc` version is `1.67.0`.
100
101 The current policy is that the minimum Rust version required to use this crate
102 can be increased in minor version updates. For example, if `crate 1.0` requires
103 Rust 1.20.0, then `crate 1.0.z` for all values of `z` will also require Rust
104 1.20.0 or newer. However, `crate 1.y` for `y > 0` may require a newer minimum
105 version of Rust.
106
107 In general, this crate will be conservative with respect to the minimum
108 supported version of Rust.