feat: add log

This commit is contained in:
2023-11-12 16:01:22 +02:00
parent c31d272e61
commit 8e99879c73
3 changed files with 8 additions and 9 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.cache/
.DS_Store
prefs.plist
.cache

View File

@@ -1,4 +0,0 @@
Query: compon, Hash: b141f617110529560a69ffb63f881cc5
Cache file: .cache/projects-b141f617110529560a69ffb63f881cc5.json
Processing results
Sending Result: map({title: (["Open Pipeline: ",.path] | join("")), subtitle: .path_with_namespace, arg:([.web_url, "/-/pipelines"] | join(""))}) | {items:.}

12
search
View File

@@ -37,14 +37,16 @@ else
find .cache -type f -mtime +7 -name '*.json' -exec rm {} \;
query=$1
hash=$(echo $query | md5 -q)
hash=$(echo "$query" | md5 -q)
log "Query: $query, Hash: $hash"
log "Query: $query, Hash: $hash"
# cache file location
fl=".cache/projects-$hash.json"
log "Cache file: $fl"
log "Attempting cache file: $fl"
if [[ ! -f $fl ]]; then
log "Cache file not found, fetching from API"
@@ -52,13 +54,13 @@ else
# project endpoint url
url="$API_BASE/$SCOPE/$ID/projects?private_token=$TOKEN&include_subgroups=true&per_page=20&search=$query"
# get and cache to file
curl $url >$fl
curl "$url" >"$fl"
fi
log "Processing results"
# build url from args and jq result
url_build=$([[ -z "$SUFFIX" ]] && echo ".web_url" || echo '([.web_url, "/-/'$SUFFIX'"] | join(""))')
url_build=$([[ -z "$SUFFIX" ]] && echo ".web_url" || echo '([.web_url, "/-/'"$SUFFIX"'"] | join(""))')
# jq query
jquery='map({title: (["Open '$URL_DESC': ",.path] | join("")), subtitle: .path_with_namespace, arg:'$url_build'}) | {items:.}'
@@ -66,5 +68,5 @@ else
log "Sending Result: $jquery"
# output items to alfred
jq "$jquery" $fl
jq "$jquery" "$fl"
fi