{"id":17251015,"url":"https://github.com/fumieval/evp","last_synced_at":"2025-03-26T06:43:45.600Z","repository":{"id":194245090,"uuid":"690411994","full_name":"fumieval/EVP","owner":"fumieval","description":"Enviroment Variable Parser","archived":false,"fork":false,"pushed_at":"2023-11-30T05:15:20.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-10T14:05:47.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fumieval.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-12T06:35:18.000Z","updated_at":"2023-09-13T15:12:12.000Z","dependencies_parsed_at":"2023-09-12T14:28:47.273Z","dependency_job_id":"c53d7a37-0d7c-4628-a86a-b17bac0f24eb","html_url":"https://github.com/fumieval/EVP","commit_stats":null,"previous_names":["fumieval/evp"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2FEVP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2FEVP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2FEVP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fumieval%2FEVP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fumieval","download_url":"https://codeload.github.com/fumieval/EVP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245605709,"owners_count":20643030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T06:50:09.287Z","updated_at":"2025-03-26T06:43:45.580Z","avatar_url":"https://github.com/fumieval.png","language":"Haskell","readme":"EVP: Environment Variable Parser\n====\n\nEVP is a simple environment parser which focues on these three aspects:\n\n* Ease of use: no complicated machinery is needed\n* Observability: for each environment variable, EVP logs the parsed value or an error. An error does not interrupt the parsing process and it checks all the variables exhaustively.\n* Composability: environment parsers can be composed via the Applicative structure.\n\nExample\n----\n\nThe following code is a complete example demonstrating how to use EVP:\n\n```haskell\n{-# LANGUAGE ApplicativeDo #-}\n{-# LANGUAGE OverloadedStrings #-}\n\nimport EVP qualified\n\nmain :: IO ()\nmain = EVP.scan parser\n\n-- ApplicativeDo is important here because Scan is not a monad.\nparser :: EVP.Scan ()\nparser = do\n    -- @secret@ masks the parsed value\n    _token \u003c- EVP.secret $ EVP.string \"API_TOKEN\"\n    -- parse the environment variable as a YAML value\n    _port \u003c- EVP.yaml \"HTTP_PORT\"\n    -- obtain the environment variable as is\n    _foo \u003c- EVP.string \"FOO\"\n    -- you can also provide a default value\n    _debug \u003c- EVP.yaml $ \"DEBUG_MODE\" `EVP.defaultsTo` False\n    pure ()\n```\n\nRunning this code produces the following output.\n\n```\n[EVP Info] API_TOKEN: \u003cREDACTED\u003e\n[EVP Info] HTTP_PORT: 8080\n[EVP Info] FOO: foo\n[EVP Info] DEBUG_MODE: False (default)\n```\n\nRevealing unused variables\n----\n\nEVP has a mechanism to detect unused variables.\n\nIf your application's environment variables has a common prefix `MYAPP_`, you can set `assumePrefix` as a `unusedLogger`.\n\n```haskell\nEVP.scanWith EVP.def\n    { EVP.unusedLogger = EVP.assumePrefix \"MYAPP_\" }\n    parser\n```\n\nIf an environment variable prefixed by `MYAPP_` is set but not referred to, EVP prints the following warning. This is useful for detecting typos too.\n\n```\n[EVP Warn] MYAPP_OBSOLETE_FLAG is set but not used\n```\n\nAlternatively, you can also name unwanted variables individually:\n\n```haskell\nEVP.scanWith EVP.def\n    { EVP.unusedLogger = EVP.obsolete [\"OBSOLETE_VAR\"] }\n```\n\nThese can be combined using the `Semigroup` instance.\n\n```haskell\nEVP.scanWith EVP.def\n    { EVP.unusedLogger = EVP.assumePrefix \"MYAPP_\" \u003c\u003e EVP.obsolete [\"OBSOLETE_VAR\"] }\n    parser\n```\n\nParser group\n----\n\nYou can provide an additional context to a parser by applying `group \"group name\"`.\nGroup names appear in the log messages:\n\n```\n[EVP Info] DEBUG_MODE: False (default)\n[EVP Info/MySQL] MYSQL_HOST: localhost\n[EVP Info/MySQL] MYSQL_PASSWORD: \u003cREDACTED\u003e\n[EVP Error/MySQL] Failed to parse MYSQL_PORT=blah: Aeson exception:\n[EVP Error/MySQL] Error in $: parsing Int failed, expected Number, but encountered String\n```\n\nDesign context\n----\n\n* If `Scan` were a monad, the parsing process would be non-deterministic. This might cause a burden when there are two or more problems in the environment variables, because it is not possible to reveal all problems in a non-deterministic context.\n* It is recommended to avoid falling back to default values expect for debugging features. If the application configuration has an error such as a typo, it is much safer to exit than launching anyway with a default value.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffumieval%2Fevp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffumieval%2Fevp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffumieval%2Fevp/lists"}