Developing Alfred5 workflow using alfred5 python package

programming, alfred5, alfred workflow, python, macOS

DALLE_2023-11-01_01.15.53_-_Hand-drawn_illustration_of_an_incredibly_sweet_and_friendly-looking_eagle_sitting_at_a_computer_using_Visual_Studio_wearing_an_Alfred5_hat._The_eagle.png

🔰 How to Create Workflow

2oDMChr.png
IMVWNDm.png
WicJKBN.png
AwPNT8Y.png
DALLE_2023-11-01_01.17.40_-_Hand-drawn_illustration_of_an_engineer_eagle_creating_the_architecture_of_a_software_project.The_eagle_looks_focused_and_determined_wearing_glasses.png

Preparing to Code Workflow using alfred5 package and python

Init your project directory

~ MindEase Theme
  • Create src folder

  • Put your codes and requirements.txt to src folders

Install [`alfred5`](https://github.com/yemreak/alfred5)
Append the top of the `main.py`
  • If u want to use different -target for ex . use WorkflowClient.run(packagedir=".")

If you use `vscode`, add the code that below to `.vscode/settings.json` to debug your file

~ MindEase Theme

⚠️ If u installed all of requirements, dont need to create requirements.txt file in src

DALLE_2023-11-01_01.17.41_-_Hand-drawn_illustration_of_an_intellectual_eagle_trying_to_understand_a_complex_software_project._This_eagle_wears_reading_glasses_and_is_deep_in_thou.png

Understanding alfred5 use-cases

  • Via SnippetsClient API create custom snippets programmaically

  • Via WorkflowClient API create custom alfred workflow

    • Craete requirements.txt file for your python project to let alfred5 installs them if needed 🙃

    • To install from requirements.txt do all import packages inside main

    • Use global keyword to access imported packages globally

      • client.query is the query string

      • client.page_count is the page count for pagination results

    • Dont need to add alfred5 to requirements.txt

  • Use WorkflowClient.log to log your message to alfred debugger

  • Use WorkflowClient(main, cache=True) method to use caching system

    • Just do it for static (not timebased nor any dynamic stuff) response

    • Db path is db/results.yml also you can see it from workflow debug panel

DALLE_2023-11-01_01.20.02_-_Hand-drawn_illustration_of_a_contented_eagle_sitting_beside_its_computer_which_has_a_prominent_Python_logo_on_the_screen.The_eagle_having_solved_a.png

⭐️ Example Project

tUJjVUJ.png
DALLE_2023-11-01_01.20.00_-_Illustration_of_a_triumphant_eagle_reclining_in_its_chair_laptop_beside_it_showcasing_the_Python_logo_signifying_the_completion_of_a_software_projec.png

🪪 License

Last updated

Was this helpful?