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

Cannot override command help text #569

Open
n3ziniuka5 opened this issue Sep 8, 2024 · 0 comments
Open

Cannot override command help text #569

n3ziniuka5 opened this issue Sep 8, 2024 · 0 comments

Comments

@n3ziniuka5
Copy link

I have a command defined like so:

@HelpMessage("help-4")
case object Build extends Command[CommonOptions]:
    override def names: List[List[String]] = List(List("build"))

    override def help =
        super.help.copy(helpMessage = Some(HelpMessage("help-1", "help-2", "help-3")))

    override def run(options: CommonOptions, remainingArgs: RemainingArgs): Unit = ???

And neither of help-* messages are printed when I run the app with --help or build --help.

I've managed to get help-1 text printed for this command with an ovveride in CommandsEntryPoint:

object Main extends CommandsEntryPoint:
    override val commands = List(
      Build
    )

    override def help: RuntimeCommandsHelp =
        super.help.copy(commands = commands.map(cmd => RuntimeCommandHelp(cmd.names, cmd.help, cmd.group, cmd.hidden)))

The only change in the override from the default is cmd.finalHelp was changed to cmd.help.

I think there is an issue with finalHelp implementation, which in 2.1.0-M29 is:

lazy val finalHelp: Help[_] = {
    val h =
      if (hasFullHelp) messages.withFullHelp
      else if (hasHelp) messages.withHelp
      else messages
    if (name == h.progName) h
    else h.withProgName(name)
  }

I think that instead of referencing messages it should instead reference help so that it's possible to modify it.

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

No branches or pull requests

1 participant