MyNixOS website logo
Description

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

Build Status

git-config

A simple parser for Git configuration files.

Getting Started

This project is built using Stack, make sure you have it installed before proceeding.

You can fire up an interactive session like so:

stack ghci

The library can be built or tested like so:

# Building
stack build
# Running tests
stack test

Usage

A Git configuration is a colletion of sections that contain mappings of keys to values.

For the sake of simplicity this is represented as [Section] where a Section is a collection of section names and a mapping of keys to values.

We can use the parser like so:

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
    Left error ->
      print error

If you'd like to do your own parsing you can import the individual combinators from the Text.GitConfig.Parser module.

Metadata

Version

0.1.2

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows