diff options
author | EuAndreh <eu@euandre.org> | 2022-08-13 13:17:45 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-08-13 13:17:45 -0300 |
commit | a2324725adab4fda610d39eb21d8d28bdf8f35ba (patch) | |
tree | b8d770e51d7e0703020cfd6862e890b717bcb23e /bin | |
parent | bin/player: Add working utility (diff) | |
download | dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.gz dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.xz |
bin/: Add examples to help strings
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gc | 10 | ||||
-rwxr-xr-x | bin/mkdtemp | 40 | ||||
-rwxr-xr-x | bin/mkstemp | 40 | ||||
-rwxr-xr-x | bin/pre | 14 | ||||
-rwxr-xr-x | bin/prompt | 9 | ||||
-rwxr-xr-x | bin/qr | 13 | ||||
-rwxr-xr-x | bin/tmp | 15 | ||||
-rwxr-xr-x | bin/tmpname | 14 | ||||
-rwxr-xr-x | bin/uuid | 9 | ||||
-rwxr-xr-x | bin/xmpp | 12 |
10 files changed, 175 insertions, 1 deletions
@@ -14,6 +14,16 @@ help() { Options: -h, --help show this message + + + Free disk space system-wide. + + + Examples: + + Just run it: + + $ gc EOF } diff --git a/bin/mkdtemp b/bin/mkdtemp index d012175..3729dd4 100755 --- a/bin/mkdtemp +++ b/bin/mkdtemp @@ -15,10 +15,50 @@ help() { Options: -h, --help show this message + Create a new temporary file and echo its name back. + + + Examples: + + `cd` into temporary directory: + + $ cd "$(mkdtemp)" EOF } + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + name="$(tmpname)" mkdir "$name" echo "$name" diff --git a/bin/mkstemp b/bin/mkstemp index ec92c14..4097e59 100755 --- a/bin/mkstemp +++ b/bin/mkstemp @@ -15,10 +15,50 @@ help() { Options: -h, --help show this message + Create a new temporary file and echo its name back. + + + Examples: + + Capture output into temporary file: + + $ OUT="$(mkstemp)"; cmd > "$OUT" EOF } + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + name="$(tmpname)" touch "$name" echo "$name" @@ -15,6 +15,20 @@ help() { Options: -c COLOR ANSI color to be used on the prefix text -h, --help show this message + + Prefix STDIN with PREFIX. + + + Examples: + + Prefix with 'database': + + $ ./run-db.sh | pre 'database' + + + Prefix with yellow 'numbers': + + $ seq 10 | pre -c yellow numbers EOF } @@ -20,6 +20,15 @@ help() { Display a prompt and return a value corresponding to the response. + + + Examples: + + Conditionally run download command + + if prompt 'Download files?'; then + run_download; + fi EOF } @@ -16,7 +16,20 @@ help() { -s PIXEL_SIZE size of the pixel (default 10) -h, --help show this help message + Read data from STDIN and present a QR image with said data. + + + Examples: + + Link to my homepage: + + $ printf 'https://euandre.org' | qr + + + Numbers with a smaller pixel size: + + $ seq 99 | qr -s 5 EOF } @@ -16,6 +16,21 @@ help() { Options: -d delete the remote "tmp/" folder -h, --help show this message + + + Copies a file to the public server. + + + Examples: + + Copy f.txt: + + $ tmp f.txt + + + Cleanup the $REMOTE: + + $ tmp -d EOF } diff --git a/bin/tmpname b/bin/tmpname index d83fc87..89d7e4d 100755 --- a/bin/tmpname +++ b/bin/tmpname @@ -15,10 +15,24 @@ help() { Options: -h, --help show this message + Generate a temporary name. + + + Examples: + + Create a temporary file: + + $ OUT="$(tmpname)"; touch "$OUT"; cmd > "$OUT" + + + `cd` into a temporary directory: + + $ DIR="$(tmpname)"; mkdir -p "$DIR"; cd "$DIR" EOF } + for flag in "$@"; do case "$flag" in --) @@ -15,7 +15,16 @@ help() { Options: -h, --help show this message + Generate UUID from /dev/random. + + + Examples: + + Generate a UUID: + + $ uuid + 755244c8-f955-16df-75cc-f25600c90422 EOF } @@ -18,7 +18,17 @@ Options: -h, --help show this message FROM_JID the address used to send the message from - TO_JID the addresses where to send the message to""" + TO_JID the addresses where to send the message to + + +Send a one-off XMPP message. + + +Examples: + + Send a message to eu@euandreh.xyz: + + $ xmpp -m 'Hello, XMPP!' eu@euandreh.xyz""" class SendMsgBot(slixmpp.ClientXMPP): def __init__(self, jid, password, on_start): |