Skip to content

Commit 30504be

Browse files
authored
Add some explanations on implicit sub-commands in -help (#1587)
1 parent 1d80196 commit 30504be

File tree

1 file changed

+14
-2
lines changed
  • modules/cli/src/main/scala/scala/cli/commands/default

1 file changed

+14
-2
lines changed

modules/cli/src/main/scala/scala/cli/commands/default/Default.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@ class Default(
1818
isSipScala: Boolean
1919
) extends ScalaCommand[DefaultOptions] {
2020

21-
private def defaultHelp: String = actualHelp.help(ScalaCliHelp.helpFormat)
22-
private def defaultFullHelp: String = actualHelp.help(ScalaCliHelp.helpFormat, showHidden = true)
21+
private lazy val defaultCommandHelp: String =
22+
s"""
23+
|
24+
|When no subcommand is passed explicitly, an implicit subcommand is used based on context:
25+
| - if the '--version' option is passed, it prints the 'version' subcommand output, unmodified by any other options
26+
| - if any inputs were passed, it defaults to the 'run' subcommand
27+
| - additionally, when no inputs were passed, it defaults to the 'run' subcommand in the following scenarios:
28+
| - if a snippet was passed with any of the '--execute*' options
29+
| - if a main class was passed with the '--main-class' option alongside an extra '--classpath'
30+
| - otherwise, if no inputs were passed, it defaults to the 'repl' subcommand""".stripMargin
31+
32+
private def defaultHelp: String = actualHelp.help(ScalaCliHelp.helpFormat) + defaultCommandHelp
33+
private def defaultFullHelp: String =
34+
actualHelp.help(ScalaCliHelp.helpFormat, showHidden = true) + defaultCommandHelp
2335

2436
override def group = "Main"
2537
override def sharedOptions(options: DefaultOptions): Option[SharedOptions] = Some(options.shared)

0 commit comments

Comments
 (0)