Skip to content

How would someone put multiline "script" in switch? #138

Answered by nat-n
mgzenitech asked this question in Q&A
Discussion options

You must be logged in to vote

Accessing arguments as python variables only works for script or expr tasks, but shell tasks using python as an interpreter aren't as clever because they work by passing a whole script to the python interpreter, rather than composing one dynamically from the given components.

For shell tasks you can access the arg value as an environment variable like so:

[tool.poe.tasks.build]
shell = """
  from os import environ
  print(environ.get("DF_PATH"))
"""
interpreter = "python"

  [[tool.poe.tasks.build.args]]
  name       = "DF_PATH"
  options    = ["--path", "-p"]
  positional = true
  default    = "./Dockerfile"
  help       = "Path to the Dockerfile"

Notice I avoided calling the variable path

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mgzenitech
Comment options

@nat-n
Comment options

Answer selected by mgzenitech
@mgzenitech
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants