Skip to content

Using argument values to interpolate into task env values in cmd/shell tasks? #194

@tfh-cri

Description

@tfh-cri

I'm trying to use a task along the lines of:

[tool.poe.tasks.env-from-arg]
args = [
  { name = 'project', type='string', options=['--project'], default="staging" }
]
env = { ENV_PROJECT = "--someflags=${project}-suffix" }
cmd = "echo raw arg is ${project} and value from env is $ENV_PROJECT"

but on invocation the ENV_PROJECT value isn't interpolated as I'd ( perhaps naively) expect:

-> % poe -vv env-from-arg
Poe => echo raw arg is staging and value from env is --someflags=-suffix
raw arg is staging and value from env is --someflags=-suffix

-> % poe -vv env-from-arg --project somevalue
Poe => echo raw arg is somevalue and value from env is --someflags=-suffix
raw arg is somevalue and value from env is --someflags=-suffix

I suspect this might be a result of the order of operations/expansions of the task settings - because the args are passed into envvars themselves, and because they override the task.env settings and other inherited stuff, they're not actually available to support this sort of usage?

Is this intended behaviour, or could it potentially update task.env to set the arg values prior to expanding the task definitions, then a second time after to ensure overrides behave as expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions