Crates.io | xpad |
lib.rs | xpad |
version | 0.1.0 |
source | src |
created_at | 2018-02-28 00:00:10.25627 |
updated_at | 2018-02-28 00:00:10.25627 |
description | Command line tool to pad delimited fields into neat columns |
homepage | |
repository | https://github.com/coriolinus/pad |
max_upload_size | |
id | 53121 |
size | 11,128 |
pad
: command line text paddingSometimes you have a command line sequence from which you need to cut
some columns. Sometimes getting that command to work right requires that you previously tr -s ' '
. Sometimes you have this solution all coded up before discovering the column -t
command.
In that case, you need pad
.
$ pad -h
pad 0.1.0
Peter Goodspeed-Niklaus <peter.r.goodspeedniklaus@gmail.com>
USAGE:
pad [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-a, --align <align>... Specify a column's alignment. May be repeated.
-d, --delimiter <delim> Specify the delimiter with which to distinguish input fields
-f, --file <file> Read from the named file instead of stdin
-s, --separator <sep> Specify the separator with which to separate output fields
If an input file is specified, that file is read. Otherwise, pad
reads from standard input.
The input is split into columns according to the delimiter, and space-padded such that every column has consistent width. It is then output with the separator separating the columns.
Columns are aligned left by default, though column alignment may be set per column using the -a
option:
The -a
option must be specified once per column, and sets columns starting from the leftmost.
$ ls -l | tr -s ' ' | cut -d' ' -f5,9 | pad
11469 Cargo.lock
216 Cargo.toml
0 README.md
512 src
512 target
$ ls -l | tr -s ' ' | cut -d' ' -f5,9 | pad -ar -ac
11469 Cargo.lock
216 Cargo.toml
0 README.md
512 src
512 target
$ cat Cargo.toml | grep -Po "\d+\.\d+\.\d+" | pad -d. -s. -ar -ar -ar
0. 1.0
2.30.0
0. 1.1
0. 7.6
1. 2.0
$ pad -f .gitignore -d'/'
target
** *.rs.bk
Cargo.lock
$ pad -d = -f Cargo.toml -s = -ar | tail -n4
clap = "2.30.0"
failure = "0.1.1"
itertools = "0.7.6"
unicode-segmentation = "1.2.0"