From 6419d9246d969483d1fec361095f723d484672e8 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Mon, 9 Mar 2020 12:38:05 -0700 Subject: [PATCH 1/3] Add cht.sh plugin --- plugins/available/cht-sh.plugin.bash | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/available/cht-sh.plugin.bash diff --git a/plugins/available/cht-sh.plugin.bash b/plugins/available/cht-sh.plugin.bash new file mode 100644 index 00000000..bc9dcd6c --- /dev/null +++ b/plugins/available/cht-sh.plugin.bash @@ -0,0 +1,9 @@ +cite about-plugin +about-plugin 'Simplify `curl cht.sh/` to `cht.sh `' + +# Play nicely if user already installed cht.sh cli tool +if ! _command_exists cht.sh ; then + function cht.sh () { + curl "cht.sh/$1" + } +fi From 8e9dadfaad19d71d6901dd76013bc27607235645 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 10 Mar 2020 22:58:39 -0700 Subject: [PATCH 2/3] Adds metadata + support for multiple arguments --- plugins/available/cht-sh.plugin.bash | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/available/cht-sh.plugin.bash b/plugins/available/cht-sh.plugin.bash index bc9dcd6c..92846989 100644 --- a/plugins/available/cht-sh.plugin.bash +++ b/plugins/available/cht-sh.plugin.bash @@ -4,6 +4,17 @@ about-plugin 'Simplify `curl cht.sh/` to `cht.sh `' # Play nicely if user already installed cht.sh cli tool if ! _command_exists cht.sh ; then function cht.sh () { - curl "cht.sh/$1" + about 'Executes a cht.sh curl query using the provided arguments' + param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]' + example '$ cht.sh :help' + example '$ cht.sh :list' + example '$ cht.sh tar' + example '$ cht.sh js "parse json"' + example '$ cht.sh python :learn' + example '$ cht.sh rust :list' + group 'cht-sh' + + local query=$(IFS=/ ; echo "$*") + curl "cht.sh/${query}" } fi From ab7f15bee15cc75c85aad3bed212d124925c6f29 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 10 Mar 2020 23:02:33 -0700 Subject: [PATCH 3/3] Added a comment --- plugins/available/cht-sh.plugin.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/available/cht-sh.plugin.bash b/plugins/available/cht-sh.plugin.bash index 92846989..63e3c9b7 100644 --- a/plugins/available/cht-sh.plugin.bash +++ b/plugins/available/cht-sh.plugin.bash @@ -14,6 +14,7 @@ if ! _command_exists cht.sh ; then example '$ cht.sh rust :list' group 'cht-sh' + # Separate arguments with '/', preserving spaces within them local query=$(IFS=/ ; echo "$*") curl "cht.sh/${query}" }