fix(gi): soften boilerplate errors and add empty-prompt message

- Missing GITIGNORE_BOILERPLATE var/file now prints error but continues
  to the API prompt instead of exiting the function
- Empty Enter at the pattern prompt now prints "No patterns selected.
  Skipping API fetch." instead of silently returning
This commit is contained in:
2026-05-23 00:07:57 -04:00
parent 08ae7cbd5e
commit 9f917be2b2
+5 -6
View File
@@ -89,14 +89,10 @@ function gi --description 'Generate .gitignore files using the gitignore.io API'
if not set -q GITIGNORE_BOILERPLATE if not set -q GITIGNORE_BOILERPLATE
set_color red --bold set_color red --bold
echo "Error:" (set_color normal)"\$GITIGNORE_BOILERPLATE environment variable is not defined" >&2 echo "Error:" (set_color normal)"\$GITIGNORE_BOILERPLATE environment variable is not defined" >&2
return 1 else if not test -f "$GITIGNORE_BOILERPLATE"
end
if not test -f "$GITIGNORE_BOILERPLATE"
set_color red --bold set_color red --bold
echo "Error:" (set_color normal)"Boilerplate file not found at '$GITIGNORE_BOILERPLATE'" >&2 echo "Error:" (set_color normal)"Boilerplate file not found at '$GITIGNORE_BOILERPLATE'" >&2
return 1 else
end
set -l template_hash "" set -l template_hash ""
if command -q md5sum if command -q md5sum
set template_hash (md5sum "$GITIGNORE_BOILERPLATE" | string split ' ')[1] set template_hash (md5sum "$GITIGNORE_BOILERPLATE" | string split ' ')[1]
@@ -115,6 +111,7 @@ function gi --description 'Generate .gitignore files using the gitignore.io API'
echo (set_color green)"✔"(set_color normal)" Appended boilerplate to "(set_color cyan)"$readable_path"(set_color normal) echo (set_color green)"✔"(set_color normal)" Appended boilerplate to "(set_color cyan)"$readable_path"(set_color normal)
end end
end end
end
# Prompt mode: ask for patterns, fetch and dedup each one individually # Prompt mode: ask for patterns, fetch and dedup each one individually
if test $do_prompt -eq 1 if test $do_prompt -eq 1
@@ -132,6 +129,8 @@ function gi --description 'Generate .gitignore files using the gitignore.io API'
end end
__gi_append_dedup "$content" "$pattern" "$gitignore_path" "$readable_path" __gi_append_dedup "$content" "$pattern" "$gitignore_path" "$readable_path"
end end
else
echo (set_color brblack)"No patterns selected. Skipping API fetch."(set_color normal)
end end
return 0 return 0
end end