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

Wrong error reporting on multiline script issues #32

Open MartinHelmut opened 3 years ago

MartinHelmut commented 3 years ago

Given a faulty litr.toml

[commands]
update = "git pull && git submodule update --init"
build = [
  """cmake -GNinja %{trace '-DDISASSEMBLE=ON -DTRACE=ON'} \
  -DCMAKE_BUILD_TYPE=%{target} \
  --build build/%{target go0}""",
  "ninja -C build/%{target}"
]
run = "./build/%{target foo}/src/client/Client"
test = "cd build/%{target 12}/src/tests && ctest && cd ../../../.."

[params.target]
shortcut = "t"
description = "Define the application build target."
type = ["debug", "release", "profile", "trace"]
default = "debug"

[params.trace]
shortcut = "r"
description = "Activate tracing support."
type = "boolean"

Will produce the following error:

Error: Problem parsing script!
  → /Users/martin/Projects/krieselreihe/litr/litr.toml
10 | test = "cd build/%{target 12}/src/tests && ctest && cd ../../../.."
   |                           └─ Cannot parse: Unexpected character.
 ...
4 |   """cmake -GNinja %{trace '-DDISASSEMBLE=ON -DTRACE=ON'} \
  |                                                                                                               └─ Cannot parse at `go0`: Expected `}`.
 ...
9 | run = "./build/%{target foo}/src/client/Client"
  |                           └─ Cannot parse at `foo`: Expected `}`.

The issue is the error pointer placed too far right (scroll right) due to the multiple lines used inside the script and the "line length" calculated based on that.