1111import click
1212from ualfred import Workflow3
1313
14- WORKFLOW_BASE_FILES = ["info.plist" , "workflow_main.py" , "__init__.py" ]
15- # AFW_ENTRY_POINT_FILE = "afw_entry_point.py"
16- AFW_ENTRY_POINT_FILE = "afw.py"
17- AFW_REQUIREMENTS = ["click" ]
14+ from afw_runtime import afw_responses_to_feedback
15+
16+ AFW_RUNTIME_FILES = ["afw.py" , "afw_runtime.py" ]
17+ AFW_REQUIREMENTS = ["click" , "ualfred" ]
18+
19+ AFW_WORKFLOW_BASIC_FILES = ["info.plist" , "main.py" ]
1820
1921
2022@click .group ()
@@ -74,21 +76,22 @@ def build(workflow_path: str):
7476 package_file .write (file , arcname = arc_name )
7577
7678 print ("Add workflow files..." )
77- workflow_files : list [str ] = WORKFLOW_BASE_FILES
79+ workflow_files : list [str ] = AFW_WORKFLOW_BASIC_FILES
7880 icon_file = package_info .get ("icon" )
7981 if icon_file :
8082 workflow_files .append (icon_file )
8183
8284 for file in workflow_files :
8385 package_file .write (workflow_path .joinpath (file ), arcname = file )
8486
85- package_file .write (AFW_ENTRY_POINT_FILE )
87+ for file in AFW_RUNTIME_FILES :
88+ package_file .write (file )
8689
8790 package_file .close ()
8891 print (f"Create Alfred workflow[{ package_path } ] finished." )
8992
9093
91- def main (workflow ):
94+ def afw_entry (workflow ):
9295 # The Workflow3 instance will be passed to the function
9396 # you call from `Workflow3.run`.
9497 # Not super useful, as the `wf` object created in
@@ -104,10 +107,13 @@ def main(workflow):
104107 # This is also necessary for "magic" arguments to work.
105108 # args = wf.args
106109
110+ args = [workflow .args [1 ]]
111+
107112 # Do stuff here ...
108- from workflow_main import call_workflow
113+ from main import main as afw_workflow_main
109114
110- feedback = call_workflow (workflow )
115+ responses = afw_workflow_main (args , workflow .logger )
116+ feedback = afw_responses_to_feedback (responses )
111117
112118 # Add an item to Alfred feedback
113119 # wf.add_item(u'Item title', u'Item subtitle')
@@ -128,7 +134,7 @@ def call(query):
128134 # Call your entry function via `Workflow3.run()` to enable its
129135 # helper functions, like exception catching, ARGV normalization,
130136 # magic arguments etc.
131- sys .exit (wf .run (main ))
137+ sys .exit (wf .run (afw_entry ))
132138
133139
134140@cli .command ()
0 commit comments