Skip to content

Cannot override command help text #569

@n3ziniuka5

Description

@n3ziniuka5

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions