aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs32
1 files changed, 25 insertions, 7 deletions
diff --git a/app/Main.hs b/app/Main.hs
index d69530f..0faff19 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -109,7 +109,8 @@ data Command
internalTags :: Bool
}
| Show
- { id :: String
+ { id :: String,
+ width :: Maybe Int
}
deriving (Show)
@@ -130,7 +131,10 @@ listCmd =
<*> internalTagsFlag
showCmd :: O.Parser Command
-showCmd = Show <$> idArg
+showCmd =
+ Show
+ <$> idArg
+ <*> widthOption
filesArg :: O.Parser [String]
filesArg = O.many (O.strArgument (O.metavar "FILE" <> O.action "file"))
@@ -152,6 +156,18 @@ idArg =
)
)
+widthOption :: O.Parser (Maybe Int)
+widthOption =
+ O.optional
+ ( O.option
+ O.auto
+ ( O.long "width"
+ <> O.short 'w'
+ <> O.metavar "INT"
+ <> O.help "Wheather to insert line breaks after at most that many characters."
+ )
+ )
+
die :: String -> IO a
die s = do
printf "error: %s\n" s
@@ -180,7 +196,7 @@ main = do
)
)
issues
- Show {id} -> do
+ Show {id, width} -> do
issues <- listIssues [] []
case find ((==) (Just id) . I.id) issues of
Nothing -> die (printf "no issue with id `%s'\n" id)
@@ -201,10 +217,12 @@ main = do
++ fromMaybe "" (fmap T.unpack issue.description)
)
)
- -- TODO Make columns configurable
- --
- -- @topic formatting
- "mdcat --columns 80 --local"
+ ( case width of
+ Nothing ->
+ "mdcat --local"
+ Just width' ->
+ String.fromString (printf "mdcat --columns %d --local" width')
+ )
)
putDoc $
P.pretty $