From 1dde19b099be318b5e03ff7782cf7a31bc4ee76b Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 7 Oct 2022 21:31:25 -0400 Subject: [PATCH] Use getopt(1) to allow specifying channel to ping --- README | 4 ---- irl.sh | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/README b/README index 1412112..72dde5e 100644 --- a/README +++ b/README @@ -9,7 +9,3 @@ diff(1) to determine which ones are new (since the last run). It then uses nc(1) to connect to the IRC server running on localhost:6667 (which happens to be the case for our garbash tilde). - -TODO: - -* Use getopt(1) to allow passing the server/channel to notify diff --git a/irl.sh b/irl.sh index 77d9a13..a821876 100755 --- a/irl.sh +++ b/irl.sh @@ -7,11 +7,41 @@ die() { exit 1 } +usage() { + die 'Usage: irl.sh -c CHANNEL [-h HOST] [-p PORT]' +} + +port=6667 +host=localhost + +args=$(getopt c:h:p: $*) +if [ $? -ne 0 ]; then + usage +fi + +set -- $args +while [ $# -ne 0 ]; do + case "$1" + in + -c) + channel="$2"; shift; shift;; + -h) + host="$2"; shift; shift;; + -p) + port="$2"; shift; shift;; + --) + shift; break;; + esac +done + +[ -z "$channel" ] && usage + + notify() { - nc localhost 6667 </dev/null + nc $host $port </dev/null NICK rssbot -USER rssbot rssbot localhost :rssbot -PRIVMSG #garbash :New post '$1' here: $2 +USER rssbot rssbot $host :rssbot +PRIVMSG #$channel :New post '$1' here: $2 QUIT EOM } -- libgit2 1.1.1