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:
+5
-6
@@ -89,14 +89,10 @@ function gi --description 'Generate .gitignore files using the gitignore.io API'
|
||||
if not set -q GITIGNORE_BOILERPLATE
|
||||
set_color red --bold
|
||||
echo "Error:" (set_color normal)"\$GITIGNORE_BOILERPLATE environment variable is not defined" >&2
|
||||
return 1
|
||||
end
|
||||
if not test -f "$GITIGNORE_BOILERPLATE"
|
||||
else if not test -f "$GITIGNORE_BOILERPLATE"
|
||||
set_color red --bold
|
||||
echo "Error:" (set_color normal)"Boilerplate file not found at '$GITIGNORE_BOILERPLATE'" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
else
|
||||
set -l template_hash ""
|
||||
if command -q md5sum
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Prompt mode: ask for patterns, fetch and dedup each one individually
|
||||
if test $do_prompt -eq 1
|
||||
@@ -132,6 +129,8 @@ function gi --description 'Generate .gitignore files using the gitignore.io API'
|
||||
end
|
||||
__gi_append_dedup "$content" "$pattern" "$gitignore_path" "$readable_path"
|
||||
end
|
||||
else
|
||||
echo (set_color brblack)"No patterns selected. Skipping API fetch."(set_color normal)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user