feat: supports functions in bash/js/python/ruby (#6)

This commit is contained in:
sigoden
2024-05-19 22:43:49 +08:00
committed by GitHub
parent be279dcd32
commit 03c4b69822
15 changed files with 543 additions and 92 deletions
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e
# @describe Get the current weather in a given location.
# @option --location! The city and optionally the state or country, e.g., "London", "San Francisco, CA".
main() {
curl -fsSL "https://wttr.in/$(echo "$argc_location" | sed 's/ /+/g')?format=4&M"
}
eval "$(argc --argc-eval "$0" "$@")"
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e
# @describe Executes a shell command.
# @option --command~ Command to execute, such as `ls -la`
main() {
eval "$argc_command"
}
eval "$(argc --argc-eval "$0" "$@")"
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
# @describe Takes in a query string and returns search result from DuckDuckGo.
# Use it to answer user questions that require dates, facts, real-time information, or news.
# This ensures accurate and up-to-date answers.
# @meta require-tools ddgr
# @env DDG_MAX_RESULTS=5 The max results to return.
# @option --query! The query to search for.
main() {
ddgr -n $DDG_MAX_RESULTS --json "$argc_query"
}
eval "$(argc --argc-eval "$0" "$@")"
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e
# @describe Get an answer to a question using Wolfram Alpha. Input should the query in English.
# Use it to answer user questions that require computation, detailed facts, data analysis, or complex queries.
# This ensures accurate and precise answers.
# @option --query! The query to search for.
# @env WOLFRAM_API_ID!
main() {
local curl_args=(
-sSf -G
--data-urlencode "output=JSON"
--data-urlencode "format=plaintext"
--data-urlencode "input=$argc_query"
--data-urlencode "appid=$WOLFRAM_API_ID"
"https://api.wolframalpha.com/v2/query"
)
curl "${curl_args[@]}" | \
jq -r '.queryresult.pods[] | select(.subpods[0].plaintext != "")'
}
eval "$(argc --argc-eval "$0" "$@")"