Skip to content

Commit

Permalink
mini Office (13)
Browse files Browse the repository at this point in the history
  • Loading branch information
🤖 automated authored and chrisgrieser committed Oct 1, 2024
1 parent 75b6519 commit 5164dfd
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 20 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,10 @@
- Use the keyword `jg` to look for Japanese Grammar guides.
## Credits
- Hiragana/Katakana chart by [u/Moer_by](https://www.reddit.com/r/japaneseresources/comments/ilkott/hiragana_katakana_stroke_order_chart/).
- Japanese dictionary API by [jisho.org](https://jisho.org/).
- Grammar Guides at [tofugu.com](https://tofugu.com/).
- Workflow created by [Chris Grieser](https://chris-grieser.de/).</string>
- Hiragana/Katakana chart by [u/Moer_by](https://www.reddit.com/r/japaneseresources/comments/ilkott/hiragana_katakana_stroke_order_chart/)
- Japanese dictionary API by [jisho.org](https://jisho.org/)
- Grammar Guides at [tofugu.com](https://tofugu.com/)
- Workflow created by [Chris Grieser](https://chris-grieser.de/)</string>
<key>uidata</key>
<dict>
<key>23B44036-74F5-4214-9D7C-5D9D98B6A190</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>csv_file</key>
<string>~/Documents/jisho-words.csv</string>
<key>csv_metadata</key>
<string>anki</string>
<key>display_jlpt</key>
<true/>
<key>display_wanikani</key>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@
<key>hotkey</key>
<integer>9</integer>
<key>hotmod</key>
<integer>262144</integer>
<integer>524288</integer>
<key>hotstring</key>
<string>V</string>
<key>leftcursor</key>
Expand Down Expand Up @@ -1193,7 +1193,7 @@ disown</string>
<key>fixedorder</key>
<false/>
<key>items</key>
<string>[{"title":"📊 Open data folder","arg":"data_folder"},{"title":"🧹 Open cache folder","arg":"cache_folder"},{"title":"🔬 Check for unused files in current workflow"},{"title":"❗️ Restart Alfred","arg":"restart"},{"title":"🔤 Apply debugger font size","arg":"apply_debugger_fontsize"},{"title":"⚙️ Update \"Alfred Preferences.app\" icon","arg":"pref_icon"}]</string>
<string>[{"title":"📊 Open data folder","arg":"data_folder"},{"title":"🧹 Open cache folder","arg":"cache_folder"},{"title":"🔬 Check for unused files in current workflow","arg":"unused_files"},{"title":"❗️ Restart Alfred","arg":"restart"},{"title":"🔤 Apply debugger font size","arg":"apply_debugger_fontsize"},{"title":"⚙️ Update \"Alfred Preferences.app\" icon","arg":"pref_icon"}]</string>
<key>keyword</key>
<string>{var:menu_keyword}</string>
<key>matchmode</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function run() {
/** @type {AlfredItem} */
const alfredItem = {
title: variable,
subtitle: type + " · Workflow Configuration",
subtitle: type,
arg: output,
uid: variable, // only remember these
match: camelCaseMatch(variable),
Expand All @@ -70,8 +70,8 @@ function run() {
/** @type {AlfredItem} */
const alfredItem = {
title: varname,
subtitle: "Script Environment",
arg: output,
icon: { path: "Alfred.icns" }, // differentiate script env vars from workflow vars
match: camelCaseMatch(varname),
};
return alfredItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
#!/usr/bin/env zsh
# shellcheck disable=2030,2031 # apparently still works, cause it's zsh?
#───────────────────────────────────────────────────────────────────────────────

# FILES IN WORKFLOW FOLDER
current_workflow_path="$(echo "$*" | tr -d '\n')"
cd "$current_workflow_path" || return 1

echo "### $(basename "$current_workflow_path")" # for displaying in Alfred

#───────────────────────────────────────────────────────────────────────────────

# FILES IN WORKFLOW FOLDER
notfound_files=""
files=$(find . -type f \
-not -name "*.png" -not -name "*.plist" -not -name "*.d.ts" -not -name "*.md" \
-not -path "./.git*" -not -name ".*" |
cut -c3-)

# CHECK IF USED IN `info.plist`
# (only checking the `info.plist` still finds files which may be used by other scripts)
notfound=""
# CHECK IF USED IN WORKFLOW
echo "$files" | while read -r file; do
grep -q "$file" ./**/* || notfound="$notfound- $file\n"
grep -q "$file" ./**/* || notfound_files="$notfound_files- $file\n"
done

#───────────────────────────────────────────────────────────────────────────────

# UID-PNG FILES
uid_pngs=$(find . -type f -name "????????-????-????-????-????????????.png" -print0 |
xargs -0 -I {} basename {} ".png")

# CHECK IF USED IN `info.plist`
deleted_uid_pngs=""
echo "$uid_pngs" | while read -r uid; do
if ! grep -q "$uid" ./info.plist ; then
deleted_uid_pngs="$deleted_uid_pngs- $uid.png\n"
rm "./$uid.png"
fi
done
info=$([[ -z "$notfound" ]] &&
echo "✅ No unused files found for this workflow." ||
echo "⚠️ There are files not referenced in any of this workflow's files. This does not not necessary mean that they are unused, but it indicates that they might be unused.")

#───────────────────────────────────────────────────────────────────────────────

# DISPLAY IN ALFRED
echo "### $(basename "$current_workflow_path")"
echo "$info"
echo "$notfound"
if [[ -z "$notfound_files" && -z "$deleted_uid_pngs" ]]; then
echo "✅ No unused files found for this workflow."
exit 0
fi

if [[ -n "$notfound_files" ]]; then
echo "⚠️ There are files not referenced in any of this workflow's files."
echo "(This does not necessarily mean that they are unused, but is only an indicator.)"
echo "$notfound_files"
echo
fi
if [[ -n "$deleted_uid_pngs" ]]; then
echo "ℹ️ The following UID-PNG are not referenced in this workflow's \`info.plist\` and have been deleted."
echo "$deleted_uid_pngs"
fi

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 5164dfd

Please sign in to comment.