1{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE OverloadedStrings #-}
4-- Module : Gen.Types.Help
5-- Copyright : (c) 2015-2016 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)
19import Data.Char (isSpace)
21import Data.Text (Text)
22import qualified Data.Text as Text
24import Text.Pandoc.Pretty
32instance Monoid Help where
36 (Help a, Help b) -> Help (a <> b)
37 (Pan a, Pan b) -> Pan (a <> b)
38 (Raw a, Raw b) -> Raw (a <> b)
39 (Help a, b) -> Help (a <> [b])
40 (a, Help b) -> Help (a : b)
43-- | Empty Show instance to avoid verbose debugging output.
44instance Show Help where
47instance IsString Help where
48 fromString = rawHelpText . fromString
50rawHelpText :: Text -> Help
53instance FromJSON Help where
54 parseJSON = withText "help" $
55 either (fail . show) pure
60instance ToJSON Help where
71data Desc = Desc !Int Help
73instance ToJSON Desc where
74 toJSON (Desc n h) = toJSON . wrap (replicate n ' ') $ flatten h
76data Below = Below !Int Help
78instance ToJSON Below where
79 toJSON (Below n h) = toJSON . wrap (replicate n ' ' <> "-- ") $ flatten h
81flatten :: Help -> String
83 Help xs -> foldMap flatten xs
84 Pan d -> writeHaddock def d
85 Raw t -> Text.unpack t
87wrap :: String -> String -> Text
89 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