-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A simple parser for Git configuration files. -- -- git-config is a simple megaparsec parser for Git configuration -- files. -- -- It aims to provide the simplest API possible for parsing Git -- configuration files so that you can get to whatever it was you were -- doing. -- -- A sample of this library in use: -- --
-- import qualified Data.Text.IO as TIO -- import Text.GitConfig.Parser (parseConfig) -- -- main :: IO () -- main = do -- file <- TIO.readFile ".git/config" -- case parseConfig file of -- Right conf -> -- print conf --@package git-config @version 0.1.0 -- | This module provides parser-combinators for Git configuration files. -- -- It attempts to follow the syntax for Git configuration files outlined -- in this document: -- -- https://git-scm.com/docs/git-config/2.16.0#_syntax -- -- One notable omission is that no legacy compatability is explicitly -- provided (e.g. dot-separated subsection names are not guaranteed to -- parse correctly). module Text.GitConfig.Parser type Parser = Parsec Void Text data Section Section :: [Text] -> (HashMap Text Text) -> Section type GitConfig = [Section] -- | Whitespace consumer for this parser. -- -- Whitespace is considered to be any space character (including carriage -- return) as well as line comments starting with # and `;` . spaceConsumer :: Parser () -- | A lexeme for this parser. lexeme :: Parser a -> Parser a -- | A symbol for this parser. symbol :: Text -> Parser Text -- | Return a parser in between brackets. brackets :: Parser a -> Parser a -- | Return a parser in between quotes. quotes :: Parser a -> Parser a -- | Parser for escape sequences. escSeq :: Parser Char -- | Parse a section name. -- -- Section names are case-insensitive. Only alphanumeric characters, - -- and . are allowed in section names. Sections can be further divided -- into subsections. To begin a subsection put its name in double quotes, -- separated by space from the section name, in the section header. sectionName :: Parser [Text] -- | Parse a section header. -- -- A section begins with the name of the section in square brackets and -- continues until the next section begins. sectionHeader :: Parser [Text] -- | Parse a variable name. -- -- The variable names are case-insensitive, allow only alphanumeric -- characters and -, and must start with an alphabetic character. variableName :: Parser Text -- | Parse a variable value. variableValue :: Parser Text -- | Parse a tuple of Text key and value. -- -- in the form name = value (or just name, which is a short-hand to say -- that the variable is the boolean "true"). -- FIXME parse boolean true -- -- A line that defines a value can be continued to the next line by -- ending it with a ; the backquote and the end-of-line are stripped. -- Leading whitespaces after name =, the remainder of the line after the -- first comment character # or ;, and trailing whitespaces of the line -- are discarded unless they are enclosed in double quotes. Internal -- whitespaces within the value are retained verbatim. mapping :: Parser (Text, Text) -- | Parse a complete git config section. section :: Parser Section -- | Parse a complete git config. config :: Parser GitConfig parseConfig :: Text -> Either GitConfigError GitConfig instance GHC.Show.Show Text.GitConfig.Parser.Section instance GHC.Classes.Eq Text.GitConfig.Parser.Section