-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #14: Implement maximum info width setting
- Loading branch information
Showing
3 changed files
with
69 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{-# LANGUAGE ApplicativeDo #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE ViewPatterns #-} | ||
-- | Custom info width example. | ||
module Main (main) where | ||
|
||
import Env | ||
import System.Environment (getArgs) | ||
import Text.Read (readMaybe) | ||
|
||
|
||
main :: IO () | ||
main = do | ||
(readMaybe -> Just widthMax) : _ <- getArgs | ||
_ <- hello widthMax | ||
error "impossible" | ||
|
||
hello :: Int -> IO () | ||
hello n = Env.parse (header "envparse example" . Env.widthMax n) $ do | ||
_ <- var (str @String) "NAME" (help loremIpsum) | ||
_ <- var (str @String) "A_NAME_THAT_DOESN'T_FIT_IN_THE_COMPACT_VIEW" (help loremIpsum) | ||
pure () | ||
|
||
loremIpsum :: String | ||
loremIpsum = | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, \ | ||
\sed do eiusmod tempor incididunt ut labore et dolore magna \ | ||
\aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco \ | ||
\laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure \ | ||
\dolor in reprehenderit in voluptate velit esse cillum dolore eu \ | ||
\fugiat nulla pariatur. Excepteur sint occaecat cupidatat non \ | ||
\proident, sunt in culpa qui officia deserunt mollit anim id est \ | ||
\laborum." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5960149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this was a breaking change, so we should really be at 0.6 now
5960149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'm assuming you're referring to
helpDoc
changing its type, if not please elaborate!) Yeah, my bad, I wasn't paying enough attention to versioning here.5960149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5960149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no, you weren't rude; it's just that the code is 2 years old and I don't really keep envparse's source in my head too much, so I was a bit unsure if I identified the problem correctly. I'll make sure to push 0.6 today. 👍