homepage: ''
changelog-type: markdown
hash: ea60fabd6aaac47d5014572c9e5d79f4639ffd4221dc8d7d0b3fd3cd3e49ee98
test-bench-deps:
  base: '>=4.7 && <5'
  barbies-th: -any
  panfiguration: -any
maintainer: fumiaki.kinoshita@herp.co.jp
synopsis: Merge environment variables and command line options generically
changelog: |
  # Revision history for panfiguration

  ## 0.0

  * First version. Released on an unsuspecting world.
basic-deps:
  barbies: -any
  bytestring: -any
  split: -any
  base: '>=4.10 && <5'
  barbies-th: ^>=0.1.10
  text: -any
  network: -any
  optparse-applicative: -any
all-versions:
- '0.0'
author: Fumiaki Kinoshita
latest: '0.0'
description-type: markdown
description: |
  Usage
  ----

  [![Hackage](https://img.shields.io/hackage/v/panfiguration.svg)](https://hackage.haskell.org/package/panfiguration)
  ![Haskell CI](https://github.com/herp-inc/panfiguration/workflows/Haskell%20CI/badge.svg)

  Panfiguration is a library that provides a composable, automatically-derived interface for configuration parameters.

  Currently three backends are supported; `envs` for environment variables, `opts` for command-line options and `defaults` for default values.
  The `Monoid` instance makes these backends composable. See the example below for the basic usage.

  Example
  ----

  ```haskell
  import Barbies.TH
  import Panfiguration

  passthroughBareB [d|
      data ServerArgs = ServerArgs
          { http_host :: String
          , http_port :: Int
          , enable_service_log :: Bool
          , environment :: String
          }
      |]

  getServerArgs :: IO ServerArgs
  getServerArgs = run $ mconcat
      [ logger putStrLn
      , declCase snake
      , envs `withNames` \names -> names
          { http_host = "HTTP_HOST"
          , http_port = "HTTP_PORT"
          }
      , opts `asCase` kebab
      , defaults ServerArgs
          { http_host = Just "0.0.0.0"
          , http_port = Just 8080
          , enable_service_log = Just True
          , environment = Nothing -- required parameter
          }
      ]
  ```

  Naming conventions
  ----

  `declCase` specifies the naming convention of the Haskell data declaration (the default is `camel`).
  The naming conventions are configurable by the `asCase` modifier.
  By default, `envs` and `opts` uses SNAKE_CASE and kebab-case respectively.

  The following styles are supported:

  ```haskell
  AsIs
  Camel
  camel
  snake
  SNAKE
  kebab
  KEBAB
  Prefixed <str>
  ```

  You can also override individual names directly by `withNames`.
license-name: Apache-2.0

Update from Hackage at 2022-09-06T12:14:13Z
Update from Hackage at 2022-09-06T12:14:13Z
