Skip to content

Commit 67af4ec

Browse files
committed
Ensure restricted features are not mentioned in the sip --help description
1 parent 2bb0a40 commit 67af4ec

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

modules/cli/src/main/scala/scala/cli/ScalaCliCommands.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ class ScalaCliCommands(
7070
(if (pgpUseBinaryCommands) Nil else pgpCommands.allExternalCommands.toSeq) ++
7171
(if (pgpUseBinaryCommands) pgpBinaryCommands.allExternalCommands.toSeq else Nil)
7272

73-
override def description =
74-
s"$fullRunnerName is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code."
73+
override def description: String = {
74+
val coreFeaturesString =
75+
if ScalaCli.allowRestrictedFeatures then "compile, run, test and package"
76+
else "compile, run and test"
77+
s"$fullRunnerName is a command-line tool to interact with the Scala language. It lets you $coreFeaturesString your Scala code."
78+
}
79+
7580
override def summaryDesc =
7681
s"""|See '$baseRunnerName <command> --help' to read about a specific subcommand. To see full help run '$baseRunnerName <command> --help-full'.
7782
|To run another $fullRunnerName version, specify it with '--cli-version' before any other argument, like '$baseRunnerName --cli-version <version> args'.""".stripMargin

modules/integration/src/test/scala/scala/cli/integration/SipScalaTests.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ class SipScalaTests extends ScalaCliSuite {
122122
}
123123
}
124124

125+
def checkHelp(binaryName: String): Unit = TestInputs.empty.fromRoot { root =>
126+
val cliPath = os.Path(TestUtil.cliPath, os.pwd)
127+
val ext = if (Properties.isWin) ".exe" else ""
128+
val newCliPath = root / s"$binaryName$ext"
129+
os.copy(cliPath, newCliPath)
130+
131+
for { helpOption <- Seq("help", "-help", "--help") } {
132+
val res = os.proc(newCliPath, helpOption).call(cwd = root)
133+
val restrictedFeaturesMentioned = res.out.trim().contains("package")
134+
if (binaryName == "scala") expect(!restrictedFeaturesMentioned)
135+
else expect(restrictedFeaturesMentioned)
136+
}
137+
}
138+
125139
if (TestUtil.isNativeCli) {
126140
test("version command print detailed info run as scala") {
127141
runVersionCommand("scala")
@@ -130,5 +144,13 @@ class SipScalaTests extends ScalaCliSuite {
130144
test("version command print detailed info run as scala-cli") {
131145
runVersionCommand("scala-cli")
132146
}
147+
148+
test("help command mentions non-restricted features only when run as scala") {
149+
checkHelp("scala")
150+
}
151+
152+
test("help command mentions all core features when run as scala") {
153+
checkHelp("scala-cli")
154+
}
133155
}
134156
}

0 commit comments

Comments
 (0)