istCommands :: Params -> Config -> ListOptions -> IO ()
listCommands Params{colour} Config{commands} ListOptions{..} =
    putDoc $ Pretty.vsep (describe <$> commands) <> Pretty.line
  where
    describe :: NamedCommand -> Doc CommandAnn
    describe NamedCommand{name, description} =
        let commandName =
                Pretty.annotate CommandName (pretty name)

            commandDescription =
                Pretty.annotate CommandDescription (pretty description)

         in if showDescription
                then commandName <+> commandDescription
                else commandName

    putDoc = hPutDoc defaultLayoutOptions toAnsi colour stdout

    toAnsi = \case
        CommandName -> Pretty.color Pretty.Magenta
        CommandDescription -> Pretty.colorDull Pretty.White

listCommands :: Params -> Config -> ListOptions -> IO ()
listCommands Params{colour} Config{commands} ListOptions{..} =
    putDoc $ Pretty.vsep (describe <$> commands) <> Pretty.line
  where
    describe :: NamedCommand -> Doc CommandAnn
    describe NamedCommand{name, description} =
        let commandName =
                Pretty.annotate CommandName (pretty name)

            commandDescription =
                Pretty.annotate CommandDescription (pretty description)

         in if showDescription
                then commandName <+> commandDescription
                else commandName

    putDoc = hPutDoc defaultLayoutOptions toAnsi colour stdout

    toAnsi = \case
        CommandName -> Pretty.color Pretty.Magenta
        CommandDescription -> Pretty.colorDull Pretty.White
listCommands Params{colour} Config{commands} ListOptions{..} =
    putDoc $ Pretty.vsep (describe <$> commands) <> Pretty.line
  where
    describe :: NamedCommand -> Doc CommandAnn
    describe NamedCommand{name, description} =
        let commandName =
                Pretty.annotate CommandName (pretty name)

            commandDescription =
                Pretty.annotate CommandDescription (pretty description)

         in if showDescription
                then commandName <+> commandDescription
                else commandName

    putDoc = hPutDoc defaultLayoutOptions toAnsi colour stdout

    toAnsi = \case
        CommandName -> Pretty.color Pretty.Magenta
        CommandDescription -> Pretty.colorDull Pretty.White