6. Examples

6.1. Sort

$ spy -mc sorted < test.txt
file
five
has
lines
this

Similarly:

$ spy -mc reversed < test.txt
lines
five
has
file
this

6.2. Filter

$ spy -l -fc 'len == 4' < test.txt
this
file
five

6.3. Enumerate

Naively:

$ spy -m "['{}: {}'.format(n, v) for n, v in enumerate(pipe, 1)]" < test.txt
1: this
2: file
3: has
4: five
5: lines

Taking advantage of spy piping:

$ spy -m 'enumerate(pipe, 1)' -i '{}: {}' < test.txt
1: this
2: file
3: has
4: five
5: lines

6.4. Convert CSV to JSON

$ spy -c csv.DictReader -c list -c json.dumps < thing.csv > thing.json