pcapriotti / pcapriotti/optparse-applicative

How do I print help info with colored command names?

Open
#478 14 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
959
Forks
123
Avg merge
3d 19h
Merged PRs (30d)
1

Description

Hello! I'm having trouble finding a solution to this. Is something like this currently possible?

optparse-applicative version: 0.17.0.0

Currently, what I tried to so far -


import Options.Applicative (Parser, (<**>))
import qualified Options.Applicative as O
import qualified Options.Applicative.Help as OH

main :: IO ()
main = pure =<< O.customExecParser (O.prefs O.showHelpOnEmpty) opts
  where
    opts =
      O.info
        (myCommands <**> O.helper)
        ( O.fullDesc <> O.progDesc "")

myCommands :: Parser a
myCommands =
  O.subparser $
    O.command
      "myCommand"
      ( O.info
          O.empty
          (O.progDesc "description here")
      )
      <> O.style OH.green

but I got the "metavar" part of it colored green instead, not myCommand which is what I'm looking for:
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Options.Applicative.Help and the customExecParser/style usage shown in the example, then reproduce the output with optparse-applicative 0.17.0.0. Determine whether styling can apply to the command name rather than its metavar; done means help output colors myCommand while leaving the metavar behavior correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.