Closed pawelprazak closed 10 months ago
scala-cli
invokes scalafmt
under the hood, and the stderr
/stdout
channels are inherited.
The same can be achieved when launching the scalafmt
CLI class directly from cs
cs launch org.scalameta:scalafmt-cli_2.13:3.7.14 -M org.scalafmt.cli.Cli -- --check --respect-project-filters 2>&1|grep "tests"
# --- a/Users/pchabelski/IdeaProjects/scala-cli-tests/fmt-stderr/Hello.scala
# +++ b/Users/pchabelski/IdeaProjects/scala-cli-tests/fmt-stderr/Hello.scala
or scalafmt
directly
scalafmt --check --respect-project-filters 2>&1 | grep "tests"
# --- a/Users/pchabelski/IdeaProjects/scala-cli-tests/fmt-stderr/Hello.scala
# +++ b/Users/pchabelski/IdeaProjects/scala-cli-tests/fmt-stderr/Hello.scala
You can raise this in https://github.com/scalameta/scalafmt, but I believe this behaviour is intentional.
Thank you for you insight. This behavior is not intuitive IMHO, because it does not follow UNIX principles.
Please consider altering the behavior in scala-cli
regardless of the upstream, to not aggregate friction.
@pawelprazak I don't know whether the scala-cli maintainers would consider doing that if efforts to make the change upstream failed, but I'd be astonished if they did it before it was even tried. have you opened an upstream ticket?
As there seems to be no valid bug here, I'm closing ticket.
Feel free to link it in a new issue in the scalafmt
repo and continue the discussion there.
FYI, upstream works as expected with --list
:
Pawes-MBP:besom pprazak$ scalafmt --list --respect-project-filters --non-interactive core
core/src/main/scala/besom/future.scala
core/src/main/scala/besom/aliases.scala
core/src/main/scala/besom/internal/Exports.scala
core/src/test/scala/besom/internal/ContextTest.scala
core/src/main/scala/besom/internal/BesomModule.scala
core/src/main/scala/besom/internal/Input.scala
core/src/test/scala/besom/internal/DecoderTest.scala
core/src/main/scala/besom/util/NonEmptyString.scala
core/src/test/scala/besom/internal/InterpolatorTest.scala
core/src/main/scala/besom/util/interpolator.scala
core/src/test/scala/besom/internal/ResultSpec.scala
core/src/main/scala/besom/internal/Config.scala
core/src/test/scala/besom/internal/OutputTest.scala
core/src/main/scala/besom/internal/logging.scala
Pawes-MBP:besom pprazak$ scalafmt --list --respect-project-filters --non-interactive core | grep Config
core/src/main/scala/besom/internal/Config.scala
Also when --list
is provided it works with scala-cli
(with a minor unrelated problem):
scala-cli fmt . -F --list --respect-project-filters | grep "core"
/Users/pprazak/repos/besom/scripts/Packages.scala:16: error: [dialect scala3] ; expected but => found
os.read.lines(pluginsListPath).filter(_.nonEmpty).foreach: line =>
^
core/src/test/scala/besom/internal/ResultSpec.scala
core/src/test/scala/besom/internal/OutputTest.scala
core/src/test/scala/besom/internal/InterpolatorTest.scala
core/src/test/scala/besom/internal/DecoderTest.scala
core/src/test/scala/besom/internal/ContextTest.scala
core/src/main/scala/besom/util/interpolator.scala
core/src/main/scala/besom/util/NonEmptyString.scala
core/src/main/scala/besom/future.scala
core/src/main/scala/besom/aliases.scala
core/src/main/scala/besom/internal/logging.scala
core/src/main/scala/besom/internal/Input.scala
core/src/main/scala/besom/internal/Exports.scala
core/src/main/scala/besom/internal/Config.scala
core/src/main/scala/besom/internal/BesomModule.scala
I've filed an issue upstream, thank you.
Since scala-cli
aggregates this issue, I'd assume it would be helpful to leave it open for upstream issue tracking.
alright, I can leave it open.
@pawelprazak BTW what's the problem with scala-cli fmt . -F --list
you mentioned? just tested it and it seems to work as expected for me
alright, I can leave it open. @pawelprazak BTW what's the problem with
scala-cli fmt . -F --list
you mentioned? just tested it and it seems to work as expected for me
Thank you! :)
I'm sorry, my message was not clear.
I've just noticed that --list
prints to stdout as expected, in contrast to --check
printing to stderr (unexpected)
i closed the linked issue in scalafmt since it works as intended, as the intention was not for this particular use case.
Version(s) Scala CLI version: 1.0.4
Describe the bug Looks like stdout contains stderr and vice versa 🤔
To Reproduce
moreover:
Expected behaviour I should be able to grep the output form a CLI.