-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-clihelp
More file actions
executable file
·39 lines (31 loc) · 1.05 KB
/
get-clihelp
File metadata and controls
executable file
·39 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# Get CLI command help
# Environment setup
# -----------------------------------------------------------------------------
set -o pipefail
[[ ${DEBUG-} ]] && set -o xtrace
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)"
source "${SCRIPT_DIR}/bash_modules/config.sh"
source "${SCRIPT_DIR}/bash_modules/ai.sh"
function print_usage() {
cat <<EOF
Usage: $(basename "$0") <command_description>
Get Bash commands for specific tasks using AI assistance
Dependencies:
aichat AI chat command for command generation
Required arguments:
command_description The description of the command or task needed
Optional arguments:
-h, --help Show this help message and exit
EOF
}
if [[ $# -lt 1 || "${1}" == "-h" || "${1}" == "--help" ]]; then
print_usage
exit 1
fi
# Main Logic
# -----------------------------------------------------------------------------
prompt_file="${SCRIPT_DIR}/get-clihelp-prompt.md"
prompt="$(cat "${prompt_file}")"
prompt+=$'\n\n'"${*}"
eval "$(ai_get_command aichat pro "${prompt_file}" "${*}")"