diff --git a/repli b/repli index a5ea036..1c112c4 100755 --- a/repli +++ b/repli @@ -30,6 +30,7 @@ repli_usage() { printf " %s Call Replicate using a configuration file and save the result\n" "$(green "get") " printf " %s Edit the repli file\n" "$(green "edit") " printf " %s Show the repli file\n" "$(green "show") " + printf " %s Show repli environment information\n" "$(green "env") " printf " %s Get information on a model\n" "$(green "info") " printf " %s Manage templates\n" "$(green "templates")" printf " %s Manage uploaded files\n" "$(green "files") " @@ -246,6 +247,28 @@ repli_show_usage() { fi } +# :command.usage +repli_env_usage() { + printf "repli env - Show repli environment information\n\n" + + printf "%s\n" "$(bold "Usage:")" + printf " repli env\n" + printf " repli env --help | -h\n" + echo + + # :command.long_usage + if [[ -n "$long_usage" ]]; then + # :command.usage_options + printf "%s\n" "$(bold "Options:")" + + # :command.usage_fixed_flags + printf " %s\n" "$(green "--help, -h")" + printf " Show this help\n" + echo + + fi +} + # :command.usage repli_info_usage() { printf "repli info - Get information on a model\n\n" @@ -944,7 +967,7 @@ replace_embed_markers() { for file in "${files[@]}"; do if [[ ! -f "$file" ]]; then - log error "embeded file not found: $(blue "$file")" + log error "embedded file not found: $(blue "$file")" return 1 fi @@ -1228,6 +1251,30 @@ repli_show_command() { } +# :command.function +repli_env_command() { + + # src/commands/env.sh + + printf "REPLI_FILE: %s\n" "$(yellow "$REPLI_FILE")" + [[ -f "$REPLI_FILE" ]] && msg=$(green found) || msg=$(red "NOT FOUND") + printf "REPLI_FILE status: %s\n" "$msg" + printf "REPLI_OUTPUT_DIR: %s\n" "$(yellow "$output_dir")" + printf "REPLI_TEMPLATES_DIR: %s\n" "$(yellow "$templates_dir")" + printf "REPLI_LOG_LEVEL: %s\n" "$(yellow "$log_level")" + printf "REPLICATE_HOST: %s\n" "$(yellow "$replicate_host")" + + if [[ -z "$REPLICATE_API_TOKEN" ]]; then + msg=$(red "NOT SET") + else + msg="$(printf "%s...%s" "${REPLICATE_API_TOKEN:0:3}" "${REPLICATE_API_TOKEN: -3}")" + msg="$(yellow "$msg")" + fi + + printf "REPLICATE_API_TOKEN: %s\n" "$msg" + +} + # :command.function repli_info_command() { @@ -1492,6 +1539,13 @@ parse_requirements() { shift $# ;; + env) + action="env" + shift + repli_env_parse_requirements "$@" + shift $# + ;; + info | i) action="info" shift @@ -1866,6 +1920,53 @@ repli_show_parse_requirements() { } +# :command.parse_requirements +repli_env_parse_requirements() { + local key + + # :command.fixed_flags_filter + while [[ $# -gt 0 ]]; do + key="$1" + case "$key" in + --help | -h) + long_usage=yes + repli_env_usage + exit + ;; + + *) + break + ;; + + esac + done + + # :command.command_filter + action="env" + + # :command.parse_requirements_while + while [[ $# -gt 0 ]]; do + key="$1" + case "$key" in + + -?*) + printf "invalid option: %s\n" "$key" >&2 + exit 1 + ;; + + *) + # :command.parse_requirements_case + # :command.parse_requirements_case_simple + printf "invalid argument: %s\n" "$key" >&2 + exit 1 + + ;; + + esac + done + +} + # :command.parse_requirements repli_info_parse_requirements() { local key @@ -2726,6 +2827,7 @@ run() { "get") repli_get_command ;; "edit") repli_edit_command ;; "show") repli_show_command ;; + "env") repli_env_command ;; "info") repli_info_command ;; "templates") repli_templates_command ;; "templates new") repli_templates_new_command ;; diff --git a/src/bashly.yml b/src/bashly.yml index 2838662..a4123ee 100644 --- a/src/bashly.yml +++ b/src/bashly.yml @@ -102,6 +102,9 @@ commands: default: $REPLI_FILE validate: file_exists +- name: env + help: Show repli environment information + - name: info alias: i help: Get information on a model diff --git a/src/commands/env.sh b/src/commands/env.sh new file mode 100644 index 0000000..05e967f --- /dev/null +++ b/src/commands/env.sh @@ -0,0 +1,21 @@ + + + + + +printf "REPLI_FILE: %s\n" "$(yellow "$REPLI_FILE")" +[[ -f "$REPLI_FILE" ]] && msg=$(green found) || msg=$(red "NOT FOUND") +printf "REPLI_FILE status: %s\n" "$msg" +printf "REPLI_OUTPUT_DIR: %s\n" "$(yellow "$output_dir")" +printf "REPLI_TEMPLATES_DIR: %s\n" "$(yellow "$templates_dir")" +printf "REPLI_LOG_LEVEL: %s\n" "$(yellow "$log_level")" +printf "REPLICATE_HOST: %s\n" "$(yellow "$replicate_host")" + +if [[ -z "$REPLICATE_API_TOKEN" ]]; then + msg=$(red "NOT SET") +else + msg="$(printf "%s...%s" "${REPLICATE_API_TOKEN:0:3}" "${REPLICATE_API_TOKEN: -3}")" + msg="$(yellow "$msg")" +fi + +printf "REPLICATE_API_TOKEN: %s\n" "$msg" diff --git a/src/lib/replace_embed_markers.sh b/src/lib/replace_embed_markers.sh index 6120b9e..77dd7c0 100644 --- a/src/lib/replace_embed_markers.sh +++ b/src/lib/replace_embed_markers.sh @@ -11,7 +11,7 @@ replace_embed_markers() { for file in "${files[@]}"; do if [[ ! -f "$file" ]]; then - log error "embeded file not found: $(blue "$file")" + log error "embedded file not found: $(blue "$file")" return 1 fi diff --git a/test/approvals/repli b/test/approvals/repli index 46eeb64..85cc955 100644 --- a/test/approvals/repli +++ b/test/approvals/repli @@ -10,6 +10,7 @@ repli - Replicate AI Workspace Tool get Call Replicate using a configuration file and save the result edit Edit the repli file show Show the repli file + env Show repli environment information info Get information on a model templates Manage templates files Manage uploaded files diff --git a/test/approvals/repli_env b/test/approvals/repli_env new file mode 100644 index 0000000..a6fffdc --- /dev/null +++ b/test/approvals/repli_env @@ -0,0 +1,7 @@ +REPLI_FILE: tmp/repli.yaml +REPLI_FILE status: NOT FOUND +REPLI_OUTPUT_DIR: tmp +REPLI_TEMPLATES_DIR: tmp/templates +REPLI_LOG_LEVEL: debug +REPLICATE_HOST: http://localhost:3000 +REPLICATE_API_TOKEN: no-...ded diff --git a/test/approvals/repli_env_help b/test/approvals/repli_env_help new file mode 100644 index 0000000..7c0e987 --- /dev/null +++ b/test/approvals/repli_env_help @@ -0,0 +1,9 @@ +repli env - Show repli environment information + +Usage: + repli env + repli env --help | -h + +Options: + --help, -h + Show this help diff --git a/test/approvals/repli_help b/test/approvals/repli_help index 7d05f41..f265c91 100644 --- a/test/approvals/repli_help +++ b/test/approvals/repli_help @@ -10,6 +10,7 @@ repli - Replicate AI Workspace Tool get Call Replicate using a configuration file and save the result edit Edit the repli file show Show the repli file + env Show repli environment information info Get information on a model templates Manage templates files Manage uploaded files diff --git a/test/spec/env.sh b/test/spec/env.sh new file mode 100644 index 0000000..aae0448 --- /dev/null +++ b/test/spec/env.sh @@ -0,0 +1,4 @@ +describe "env" + approve "repli env --help" + approve "repli env" + \ No newline at end of file