-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-cheat-sheet.sh
More file actions
31 lines (24 loc) · 840 Bytes
/
make-cheat-sheet.sh
File metadata and controls
31 lines (24 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -o errexit
function echo_run {
echo "\$ $1"
# LIES!
# This allows me to use this code for testing with
# python 2 and python3
# whilst also producing documentation
# combining documentation with testing has a lot of
# benefits
command=$(echo $1 | sed "s_clixpath_$python -m clixpath_")
eval "$command"
}
python=${PYTHON:-python}
echo '#Basic usage'
echo_run "curl -L --silent http://xkcd.com/1833 | clixpath '//img/@src'"
echo
echo
echo '#Machine readable output (the main reason for this tool)'
echo_run "curl -L --silent http://xkcd.com/1833 | clixpath --json '//img'"
echo
echo
echo '#Extracting structured data from records (like capture groups in regexp)'
echo_run "curl -L --silent http://xkcd.com/1833 | clixpath '//img' --extract alt_text @alt --extract source @src"