Skip to content

Commit 2862c21

Browse files
committed
Add more descriptive messages for using experimental & restricted directives without the power mode enabled; tag publishing directives as experimental
1 parent 6a6c6d9 commit 2862c21

File tree

10 files changed

+15
-13
lines changed

10 files changed

+15
-13
lines changed

modules/build/src/main/scala/scala/build/preprocessing/DirectivesProcessor.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ object DirectivesProcessor {
3333
scopedDirective: ScopedDirective,
3434
logger: Logger
3535
) =
36-
if (!allowRestrictedFeatures && handler.isRestricted)
36+
if (!allowRestrictedFeatures && (handler.isRestricted || handler.isExperimental))
37+
val powerDirectiveType = if handler.isExperimental then "experimental" else "restricted"
3738
val msg =
38-
"""This directive is not supported.
39-
|Please run it with the `--power` flag or turn this flag on globally by running `config power true`.""".stripMargin
39+
s"""This directive is $powerDirectiveType.
40+
|Please run it with the '--power' flag or turn this flag on globally by running 'config power true'""".stripMargin
4041
Left(DirectiveErrors(
4142
::(msg, Nil),
4243
DirectiveUtil.positions(scopedDirective.directive.values, path)

modules/directives/src/main/scala/scala/build/preprocessing/directives/DirectiveHandler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ trait DirectiveHandler[+T] { self =>
3434
def scalaSpecificationLevel: SpecificationLevel
3535
protected def SpecificationLevel = scala.cli.commands.SpecificationLevel
3636

37-
final def isRestricted: Boolean = scalaSpecificationLevel == SpecificationLevel.RESTRICTED
37+
final def isRestricted: Boolean = scalaSpecificationLevel == SpecificationLevel.RESTRICTED
38+
final def isExperimental: Boolean = scalaSpecificationLevel == SpecificationLevel.EXPERIMENTAL
3839

3940
def keys: Seq[String]
4041

modules/directives/src/main/scala/scala/build/preprocessing/directives/Publish.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import scala.cli.commands.SpecificationLevel
2222
|""".stripMargin
2323
)
2424
@DirectiveDescription("Set parameters for publishing")
25-
@DirectiveLevel(SpecificationLevel.RESTRICTED)
25+
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)
2626
// format: off
2727
final case class Publish(
2828
organization: Option[Positioned[String]] = None,

modules/directives/src/main/scala/scala/build/preprocessing/directives/PublishContextual.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ object PublishContextual {
9999
|""".stripMargin
100100
)
101101
@DirectiveDescription("Set contextual parameters for publishing")
102-
@DirectiveLevel(SpecificationLevel.RESTRICTED)
102+
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)
103103
// format: off
104104
final case class Local(
105105
computeVersion: Option[Positioned[String]] = None,

modules/directives/src/main/scala/scala/build/preprocessing/directives/RequirePlatform.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import scala.cli.commands.SpecificationLevel
1717
"//> using target.platform _platform_",
1818
"`//> using target.platform `_platform_"
1919
)
20-
@DirectiveLevel(SpecificationLevel.RESTRICTED)
20+
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)
2121
// format: off
2222
final case class RequirePlatform(
2323
@DirectiveName("platform")

modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.cli.commands.SpecificationLevel
1313
"//> using target.scala _version_",
1414
"`//> using target.scala `_version_"
1515
)
16-
@DirectiveLevel(SpecificationLevel.RESTRICTED)
16+
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)
1717
final case class RequireScalaVersion(
1818
scala: Option[DirectiveValueParser.MaybeNumericalString] = None
1919
) extends HasBuildRequirements {

modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersionBounds.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import scala.cli.commands.SpecificationLevel
1414
"//> using target.scala.>= _version_",
1515
"`//> using target.scala.>= `_version_"
1616
)
17-
@DirectiveLevel(SpecificationLevel.RESTRICTED)
17+
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)
1818
final case class RequireScalaVersionBounds(
1919
`==`: Option[DirectiveValueParser.MaybeNumericalString] = None,
2020
`>=`: Option[DirectiveValueParser.MaybeNumericalString] = None,

modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScope.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.cli.commands.SpecificationLevel
1616
"//> using target.scope _scope_",
1717
"`//> using target.scope `_scope_"
1818
)
19-
@DirectiveLevel(SpecificationLevel.RESTRICTED)
19+
@DirectiveLevel(SpecificationLevel.EXPERIMENTAL)
2020
final case class RequireScope(
2121
scope: Option[Positioned[String]] = None
2222
) extends HasBuildRequirements {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ trait RunScalaPyTestDefinitions { _: RunTestDefinitions =>
108108
inputs.fromRoot { root =>
109109

110110
// Script dir shouldn't be added to PYTHONPATH if PYTHONSAFEPATH is non-empty
111-
val errorRes = os.proc(TestUtil.cli, "run", extraOptions, nativeOpt, "src")
111+
val errorRes = os.proc(TestUtil.cli, "--power", "run", extraOptions, nativeOpt, "src")
112112
.call(
113113
cwd = root,
114114
env = Map("PYTHONSAFEPATH" -> "foo"),
@@ -119,7 +119,7 @@ trait RunScalaPyTestDefinitions { _: RunTestDefinitions =>
119119
val errorOutput = errorRes.out.text()
120120
expect(errorOutput.contains("No module named 'helpers'"))
121121

122-
val res = os.proc(TestUtil.cli, "run", extraOptions, nativeOpt, "src")
122+
val res = os.proc(TestUtil.cli, "--power", "run", extraOptions, nativeOpt, "src")
123123
.call(cwd = root)
124124
val output = res.out.trim()
125125
if (native)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class SipScalaTests extends ScalaCliSuite {
5454
if (isRestricted) {
5555
expect(res.exitCode == 1)
5656
val output = res.out.text()
57-
expect(output.contains(s"directive is not supported"))
57+
expect(output.contains(s"directive is experimental"))
5858
}
5959
else
6060
expect(res.exitCode == 0)

0 commit comments

Comments
 (0)