Using sys.inputs
, you could have this
typst compile main.typ tasks.pdf --input=solution=false // for tasks and solution hidden
typst compile main.typ solution.pdf --input=solution=true // for solution (+ task)
without manually (un)setting the flag (or use sed).
Related: Can I configure my document (e.g. draft/release version, color theme) when creating a PDF without modifying the Typst file directly?