-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share optpars-applicative utils across executables
- Loading branch information
Showing
4 changed files
with
38 additions
and
13 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
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
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,32 @@ | ||
{-| | ||
Module : Options.Utils | ||
Description : Options.Applicative utilities | ||
License : ASL-2 | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : POSIX | ||
-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | ||
module Options.Utils where | ||
|
||
import Options.Applicative | ||
import Shelly (FilePath, fromText) | ||
import Prelude hiding (FilePath) | ||
import Data.Monoid ((<>)) | ||
import qualified Data.Text as T | ||
|
||
default (T.Text) | ||
|
||
-- | 'Text' option | ||
textOption :: Mod OptionFields String -> Parser T.Text | ||
textOption = fmap T.pack . strOption | ||
|
||
-- | 'Text' argument type | ||
text :: ReadM T.Text | ||
text = str >>= return . T.pack | ||
|
||
-- | 'FilePath' option | ||
filePathOption :: Mod OptionFields String -> Parser FilePath | ||
filePathOption = fmap fromText . textOption |