Minor refactoring.

master
Abhinav Sarkar 2016-07-06 17:24:42 +05:30
parent 7cec652d96
commit 57e76321a1
No known key found for this signature in database
GPG Key ID: 7C9166A6F5465AD5
1 changed files with 18 additions and 15 deletions

View File

@ -21,19 +21,22 @@ data ProgArgs = ProgArgs
, progOutputDir :: FilePath , progOutputDir :: FilePath
} deriving (Eq, Show) } deriving (Eq, Show)
textOption :: Mod OptionFields String -> Parser Text.Text
textOption o = Text.pack <$> strOption o
settingsParser :: Parser Settings settingsParser :: Parser Settings
settingsParser = let Settings {..} = defSettings settingsParser = let Settings {..} = defSettings
in Settings in Settings
<$> (Text.pack <$> strOption (long "dim-prefix" <$> textOption (long "dim-prefix"
<> short 'd' <> short 'd'
<> value (Text.unpack settingDimPrefix) <> value (Text.unpack settingDimPrefix)
<> showDefault <> showDefault
<> help "Prefix for dimension tables")) <> help "Prefix for dimension tables")
<*> (Text.pack <$> strOption (long "fact-prefix" <*> textOption (long "fact-prefix"
<> short 'f' <> short 'f'
<> value (Text.unpack settingFactPrefix) <> value (Text.unpack settingFactPrefix)
<> showDefault <> showDefault
<> help "Prefix for fact tables")) <> help "Prefix for fact tables")
<*> minorOption "fact-infix" <*> minorOption "fact-infix"
settingFactInfix settingFactInfix
"Infix for fact tables" "Infix for fact tables"
@ -84,11 +87,11 @@ settingsParser = let Settings {..} = defSettings
"Suffix template for table names in SQL" "Suffix template for table names in SQL"
where where
minorOption longDesc defValue helpTxt = minorOption longDesc defValue helpTxt =
Text.pack <$> strOption (long longDesc textOption (long longDesc
<> hidden <> hidden
<> value (Text.unpack defValue) <> value (Text.unpack defValue)
<> showDefault <> showDefault
<> help helpTxt) <> help helpTxt)
progArgsParser :: Parser ProgArgs progArgsParser :: Parser ProgArgs
progArgsParser = progArgsParser =