Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoprintHelpAndExit doesn't print the help message and exit when --help is passed to a subcommand #174

Open
jnowjack-lucidchart opened this issue Jan 20, 2025 · 0 comments · May be fixed by #178

Comments

@jnowjack-lucidchart
Copy link

When using multiple main methods --help is not automatically detected if passed to a subcommand.

For example:

object Main {
  @main def foo(@arg() bar: Boolean ) = {}
  @main def baz() = {}
  def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args.toSeq)
}

When run with ./example foo --help will error instead of printing the help message for foo:

Missing argument: --bar <bool>
Unknown argument: "--help"
Expected Signature: foo
  --bar <bool>

The --help arg will also get swallowed by a Leftover[String] or String* and the command will run instead of immediately exiting:

object Main {
  @main def foo(@arg() bar: String*) = { println(bar) }
  @main def bar() = {}
  def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args.toSeq)
}

When run with ./example foo --help outputs:
List(--help)

@jnowjack-lucidchart jnowjack-lucidchart linked a pull request Jan 23, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant