Skip to content

Commit

Permalink
Fix printing not supported option in restricted mode (#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwronski authored Feb 16, 2023
1 parent f601edf commit ec18a64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ object RestrictedCommandsParser {
d: D,
nameFormatter: Formatter[Name]
): Either[(Error, Arg, List[String]), Option[(D, Arg, List[String])]] =
parser.step(args, index, d, nameFormatter) match {
case Right(Some(_, arg, _)) if !arg.isSupported =>
(parser.step(args, index, d, nameFormatter), args) match {
case (Right(Some(_, arg, _)), passedOption :: _) if !arg.isSupported =>
Left((
Error.UnrecognizedArgument(
s"""`${args(index)}` option is not supported in `scala` command.
s"""`$passedOption` option is not supported in `scala` command.
|Please run it with `scala-cli` command or with `--power` flag or turn on this flag globally running command `config power true`.""".stripMargin
),
arg,
Nil
))
case other =>
case (other, _) =>
other
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class SipScalaTests extends ScalaCliSuite {

val binary = binaryName.prepareBinary(root)

val res = os.proc(binary, "--markdown", source).call(
val res = os.proc(binary, "--scala", "3", "--markdown", source).call(
cwd = root,
check = false,
mergeErrIntoOut = true
Expand All @@ -90,6 +90,7 @@ class SipScalaTests extends ScalaCliSuite {
expect(res.exitCode == 1)
val output = res.out.text()
expect(output.contains(s"option is not supported"))
expect(output.contains("--markdown"))
}
else expect(res.exitCode == 0)
}
Expand Down

0 comments on commit ec18a64

Please sign in to comment.