Skip to content

Show help document if for the invalid subcommand #1240

@tanishiking

Description

@tanishiking

Is your feature request related to a problem? Please describe.
If I provide an invalid subcommand to scala-cli, it shows a stacktrace.

$ ❯ scala-cli invalid
scala.build.errors.InputsException: invalid: not found
  scala.build.Inputs$.forNonEmptyArgs(Inputs.scala:436)
  scala.build.Inputs$.apply(Inputs.scala:471)
  scala.cli.commands.util.SharedOptionsUtil$SharedOptionsOps.inputs(SharedOptionsUtil.scala:276)
  scala.cli.commands.util.SharedOptionsUtil$SharedOptionsOps.inputsOrExit(SharedOptionsUtil.scala:231)
  scala.cli.commands.Run$.run(Run.scala:64)
  scala.cli.commands.Run$.run(Run.scala:34)
  scala.cli.commands.Default.run(Default.scala:37)
  scala.cli.commands.Default.run(Default.scala:30)
  caseapp.core.app.CaseApp.main(CaseApp.scala:149)
  caseapp.core.app.CommandsEntryPoint.main(CommandsEntryPoint.scala:120)
  scala.cli.ScalaCliCommands.main(ScalaCliCommands.scala:119)
  scala.cli.ScalaCli$.main0(ScalaCli.scala:184)
  scala.cli.ScalaCli$.main(ScalaCli.scala:83)
  scala.cli.ScalaCli.main(ScalaCli.scala)

Describe the solution you'd like
It would be helpful if scala-cli shows a help document (that is shown when we type scala-cli help) when we provide an invalid subcommand

$ scala-cli invalid
'invalid' is not a scala-cli command <- something like that

Usage: scala-cli <COMMAND>
Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code.

Other commands:
  export                                        Export current project to sbt or Mill
  help                                          Print help message
  install completions, install-completions      Installs completions into your shell
  ...

Describe alternatives you've considered
It might be better to show a small error message that recommends users to run scala-cli help.

For example, git command shows the following message for invalid command.

$ git invalid
git: 'invalid' is not a git command. See 'git --help'.

Additional context
none

Metadata

Metadata

Assignees

Labels

SIP-46All the issues related to SIP-46 to turn Scala CLI into the official scala runner command.UXWarsaw Scala SpreeenhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions