Skip to content

CLI Usage

guitarbum722 edited this page Sep 10, 2017 · 3 revisions

CLI Usage Examples

Usage: align [-h] [-f] [-o] [-q] [-s] [-d] [-a] [-c] [-i] [-p]
Options:
  -h | --help  help
  -f           input file.  If not specified, pipe input to stdin
  -o           output file. (default: stdout)
  -q           text qualifier (if applicable)
  -s           delimiter (default: ',')
  -d           output delimiter (defaults to the value of sep)
  -a           <left>, <right>, <center> justification (default: left)
  -c           output specific fields (default: all fields)
  -i           override justification by column number (e.g. 2:center,5:right)
  -p           extra padding surrounding delimiter

-f Input File

Specify an input file, if not piping to Stdin.

$ align -f input_file.csv

-o Output File

Specify an output file, if not writing to Stdout.

$ cat input.csv | align -o output_file.csv

-q Text Qualifier

Specify a text field character, especially if there is the possibility that your delimiter could be part of the data in a text field and should be ignored for alignment (avoid transposing fields during alignment). Often, the qualifier is a double or single quote.

Sample input

first,last,address,phone
john ,doe,"123 any street, apt 12",111-111-1111

Note the comma withing the street address. The input's delimiter is also a comma, so the comma within the data should not be considered during alignment. Escape it by specifying a text qualifier.

$ align -q \"

-s Separator (Input Delimiter)

The delimiter of the input data. The default is comma (,). Use this argument to specify a different input delimiter, such as | or *.

$ align -s \|

-d Output Delimiter

Specify the delimiter that should be used for output. The default will be what was specified as the input delimiter.

align -d "*"

-a Justification

Options are left, right, or center. This sets the overall justification of each field in the output. The default is left.

$ align -a right

-i Justification Overrides (Field Level Justification)

Use this option to specify the justification for particular fields in the output.

align -i 4:left,7:right,8:center

-p Additional Padding

Supply an integer value to -p to specify the amount of extra padding around each delimiter (before and after the data in each field). The default is 1 space of padding if not specified.

Regardless of justification, these examples would add extra padding to each field.

# 2 spaces of padding
$ align -p 2

# no padding
$ align -p 0

# no padding
$ align -p -1