configifier 0.0.7 → 0.0.8
raw patch · 2 files changed
+11/−11 lines, 2 filesdep −regex-easyPVP ok
version bump matches the API change (PVP)
Dependencies removed: regex-easy
API changes (from Hackage documentation)
Files
- configifier.cabal +1/−2
- src/Data/Configifier.hs +10/−9
configifier.cabal view
@@ -1,5 +1,5 @@ name: configifier-version: 0.0.7+version: 0.0.8 synopsis: parser for config files, shell variables, command line args. description: See <https://github.com/zerobuzz/configifier/blob/master/README.md README> license: AGPL-3@@ -40,7 +40,6 @@ , either >=4.3 && <4.5 , functor-infix >=0.0.3 && <0.1 , mtl >=2.1 && <2.3- , regex-easy >=0.1.0.0 && <0.2 , safe >=0.3 && <0.4 , string-conversions >=0.3 && <0.5 , template-haskell >=2.10 && <2.11
src/Data/Configifier.hs view
@@ -31,7 +31,7 @@ import Data.Either.Combinators (mapLeft) import Data.Function (on) import Data.Functor.Infix ((<$$>))-import Data.List (nubBy, intercalate, isPrefixOf)+import Data.List (nubBy, intercalate, isPrefixOf, findIndices, splitAt) import Data.Maybe (catMaybes) import Data.Monoid (Monoid, (<>), mempty, mappend, mconcat) import Data.String.Conversions (ST, SBS, cs)@@ -49,7 +49,6 @@ import qualified Data.HashMap.Strict as HashMap import qualified Data.Vector as Vector import qualified Data.Yaml as Yaml-import qualified Text.Regex.Easy as Regex -- * config types@@ -118,7 +117,7 @@ data Source = YamlString SBS- | YamlFile FilePath+ | YamlFile FilePath -- FIXME: { yamlFilePath :: FilePath, yamlFileOptional :: Bool } | ShellEnv [(String, String)] | CommandLine [String] deriving (Eq, Ord, Show, Typeable)@@ -497,14 +496,16 @@ <|> ((, t) <$> parseArgsWithSpace h h') parseArgsWithEqSign :: String -> Either String (String, String)-parseArgsWithEqSign s = case cs s Regex.=~- "^--([^=]+)=(.*)$" of- [_, k, v] -> Right (cs k, cs v)- bad -> Left $ "could not parse last arg: " ++ show (s, bad)+parseArgsWithEqSign = f+ where+ f ('-':'-':t@(findIndices (== '=') -> [i])) = Right . (\(k, '=':v) -> (k, v)) $ splitAt i t+ f s = Left $ "could not parse long-arg: " ++ show s parseArgsWithSpace :: String -> String -> Either String (String, String)-parseArgsWithSpace s v = case cs s Regex.=~- "^--([^=]+)$" of- [_, k] -> Right (cs k, cs v)- bad -> Left $ "could not parse long-arg with value: " ++ show (s, v, bad)+parseArgsWithSpace s v = f s+ where+ f ('-':'-':t) | (not . any (== '=') $ t) = Right (t, v)+ f _ = Left $ "could not parse long-arg: " ++ show (s, v) parseArgName :: String -> String parseArgName = map f