aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-13 13:17:45 -0300
committerEuAndreh <eu@euandre.org>2022-08-13 13:17:45 -0300
commita2324725adab4fda610d39eb21d8d28bdf8f35ba (patch)
treeb8d770e51d7e0703020cfd6862e890b717bcb23e /bin
parentbin/player: Add working utility (diff)
downloaddotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.gz
dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.xz
bin/: Add examples to help strings
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gc10
-rwxr-xr-xbin/mkdtemp40
-rwxr-xr-xbin/mkstemp40
-rwxr-xr-xbin/pre14
-rwxr-xr-xbin/prompt9
-rwxr-xr-xbin/qr13
-rwxr-xr-xbin/tmp15
-rwxr-xr-xbin/tmpname14
-rwxr-xr-xbin/uuid9
-rwxr-xr-xbin/xmpp12
10 files changed, 175 insertions, 1 deletions
diff --git a/bin/gc b/bin/gc
index ec6a8f1..23a0436 100755
--- a/bin/gc
+++ b/bin/gc
@@ -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"
diff --git a/bin/pre b/bin/pre
index 79c212f..2b32f8f 100755
--- a/bin/pre
+++ b/bin/pre
@@ -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
}
diff --git a/bin/prompt b/bin/prompt
index 68dff61..247c81a 100755
--- a/bin/prompt
+++ b/bin/prompt
@@ -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
}
diff --git a/bin/qr b/bin/qr
index 4821a46..c0462e1 100755
--- a/bin/qr
+++ b/bin/qr
@@ -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
}
diff --git a/bin/tmp b/bin/tmp
index e2d16b7..2dc0b48 100755
--- a/bin/tmp
+++ b/bin/tmp
@@ -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
--)
diff --git a/bin/uuid b/bin/uuid
index 74d0fba..34b685f 100755
--- a/bin/uuid
+++ b/bin/uuid
@@ -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
}
diff --git a/bin/xmpp b/bin/xmpp
index 472e9ca..b08a783 100755
--- a/bin/xmpp
+++ b/bin/xmpp
@@ -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):