1{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE OverloadedStrings #-}
4-- Module : Gen.Types.Help
5-- Copyright : (c) 2015 Brendan Hay
6-- License : Mozilla Public License, v. 2.0.
7-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
8-- Stability : provisional
9-- Portability : non-portable (GHC extensions)
18import Data.Char (isSpace)
20import Data.Text (Text)
21import qualified Data.Text as Text
23import Text.Pandoc.Pretty
31instance Monoid Help where
35 (Help a, Help b) -> Help (a <> b)
36 (Pan a, Pan b) -> Pan (a <> b)
37 (Raw a, Raw b) -> Raw (a <> b)
38 (Help a, b) -> Help (a <> [b])
39 (a, Help b) -> Help (a : b)
42-- | Empty Show instance to avoid verbose debugging output.
43instance Show Help where
46instance IsString Help where
47 fromString = rawHelpText . fromString
49rawHelpText :: Text -> Help
52instance FromJSON Help where
53 parseJSON = withText "help" $
54 either (fail . show) pure
59instance ToJSON Help where
70data Desc = Desc !Int Help
72instance ToJSON Desc where
73 toJSON (Desc n h) = toJSON . wrap (replicate n ' ') $ flatten h
75flatten :: Help -> String
77 Help xs -> foldMap flatten xs
78 Pan d -> writeHaddock def d
79 Raw t -> Text.unpack t
81wrap :: String -> String -> Text
83 Text.dropWhileEnd isSpace
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list