Question: How to check if workflow is a rerun?
snipem opened this issue · comments
Can I check if a run was invoked by Alfred by using wf.Rerun()
?
Alfred passes top-level variables back to your Script Filter on rerun, so you can set a variable, e.g. Workflow.Var("is_rerun", "true")
, and check for its existence to tell whether your Script Filter is being rerun.
I'm trying to get and set it using this snippet, while setting seems to work I can't read the variable in the subsequent run. Do you have any clue?
// get
isRerun := vars.Vars()["is_rerun"]
// set
wf.Var("is_rerun", "true")
I can't read the variable in the subsequent run
Alfred sets workflow variables as environment variables. You need to read them from the environment with os.Getenv()
or Workflow.Config.GetBool()
etc.
Workflow
doesn't import any environment variables: Workflow.Vars()
only contains variables you've added with Workflow.Var()
during that run.
If you need to load a whole bunch of environment variables, you can use Workflow.Config.To()
.