krieselreihe / litr

Litr (Language Independent Task Runner) lets you configure and then run any tasks you want for any language.
MIT License
8 stars 0 forks source link

Handle boolean and/or toggle parameter #10

Closed MartinHelmut closed 3 years ago

MartinHelmut commented 3 years ago

Sometimes you just want to activate/deactivate something based on a flag. This issue will serve to explore the how.

First draft

[commands.name]
# Is using a ternary really the solution?
script = "cmake %{name1} ... %{name2 ? 'do this' : 'do that'}"

[params.name1]
type = "boolean"
default = false

[params.name2]
type = "boolean"
default = true
MartinHelmut commented 3 years ago

More thoughts, different syntax.

Only add if true:

[commands.build]
script = "cmake %{name 'do this'}"

[params.name]
type = "boolean"

If..else style with the or keyword:

[commands.build]
script = "cmake %{name 'do this' or 'do that'}"

[params.name]
type = "boolean"

Open questions:

MartinHelmut commented 3 years ago

This will also enable special usage options for boolean parameters, e.g.:

litr build --logging=true , run --logging=false