{"id":34070062,"url":"https://github.com/florianmahner/tomlparse","last_synced_at":"2025-12-14T07:02:06.700Z","repository":{"id":65817287,"uuid":"599740021","full_name":"florianmahner/tomlparse","owner":"florianmahner","description":"argparse.ArgumentParser wrapper to parse TOML files from the command-line","archived":false,"fork":false,"pushed_at":"2025-10-14T19:34:01.000Z","size":841,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-16T01:54:38.765Z","etag":null,"topics":["argument-parser","command-line-tool","project-management","python","toml"],"latest_commit_sha":null,"homepage":"https://florianmahner.github.io/tomlparse","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/florianmahner.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":"CONTRIBUTING.rst","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-02-09T19:29:48.000Z","updated_at":"2025-10-14T18:47:39.000Z","dependencies_parsed_at":"2023-08-19T18:15:32.674Z","dependency_job_id":"8a7ea6fd-379e-499c-b272-3eed56081c6d","html_url":"https://github.com/florianmahner/tomlparse","commit_stats":null,"previous_names":["florianmahner/toml-argparse"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/florianmahner/tomlparse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianmahner%2Ftomlparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianmahner%2Ftomlparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianmahner%2Ftomlparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianmahner%2Ftomlparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/florianmahner","download_url":"https://codeload.github.com/florianmahner/tomlparse/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/florianmahner%2Ftomlparse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27720801,"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","status":"online","status_checked_at":"2025-12-14T02:00:11.348Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["argument-parser","command-line-tool","project-management","python","toml"],"created_at":"2025-12-14T07:00:54.742Z","updated_at":"2025-12-14T07:02:06.693Z","avatar_url":"https://github.com/florianmahner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tomlparse \n\n\u003ca href=\"https://github.com/florianmahner/tomlparse/blob/main/docs/logo.png?raw=true\"\u003e\u003cimg src=\"https://github.com/florianmahner/tomlparse/blob/main/docs/logo.png?raw=true\" width=\"150\" align=\"right\" /\u003e\u003c/a\u003e\n\n[![Release](https://img.shields.io/github/v/release/florianmahner/tomlparse)](https://img.shields.io/github/v/release/florianmahner/tomlparse)\n[![Build status](https://img.shields.io/github/actions/workflow/status/florianmahner/tomlparse/main.yml?branch=main)](https://github.com/florianmahner/toml-argparse/actions/workflows/main.yml?query=branch%3Amain)\n![example workflow](https://github.com/florianmahner/tomlparse/actions/workflows/main.yml/badge.svg)\n[![codecov](https://codecov.io/gh/florianmahner/tomlparse/branch/main/graph/badge.svg)](https://codecov.io/gh/florianmahner/tomlparse)\n[![License](https://img.shields.io/github/license/florianmahner/tomlparse)](https://img.shields.io/github/license/florianmahner/tomlparse)\n![code style](https://img.shields.io/badge/code%20style-black-black)\n\ntomlparse is a Python library and command-line tool that allows you to use \u003ca href=\"https://toml.io/en/\"\u003eTOML\u003c/a\u003e configuration files in conjunction with the \u003ca href=\"https://docs.python.org/3/library/argparse.html\"\u003eargparse module\u003c/a\u003e. It provides a simple and convenient way to handle your python projects, leveraging the strengths of both TOML and argparse.\n\n\n# 📝 Table of Contents\n1. [Installation](#installation)\n2. [Usage](#usage)\n    1. [Basic Example](#basic-example)\n    2. [Extended Example](#extended-example)\n5. [Contributing](#contributing)\n\n\n## 💻 How to install\n\nYou can install the library using pip\n\n```bash\npip install tomlparse\n```\n\n\n## 🔍 How to use\n\nUsing tomlparse is straightforward and requires only a few extra steps compared to using argparse alone.\n\n### 🐍 Basic Example\n\nYou first define your configuration options in a TOML file. TOML files are highly flexible and include a lot of native types. Have look [here](https://toml.io/en/v1.0.0) for an extensive list.  TOML files usually come in the following form:\n\n```toml\n# This is a very basic TOML file\nfoo = 10\nbar = \"hello\"\n```\n\nAt the core of this module is the  [TOML ArgumentParser](https://github.com/florianmahner/toml-argparse/blob/main/tomlparse/argparse.py), a simple wrapper of the original argparse module. To use the TOML arguments for our project, we we would create an `ArgumentParser` as usual:\n\n```python\nimport tomlparse\nparser = tomlparse.ArgumentParser()\nparser.add_argument(\"--foo\", type=int, default=0)\nparser.add_argument(\"--bar\", type=str, default=\"\")\nparser.parse_args()\n```\n\nThis is just a simple example with two arguments. But for larger projects with many hyperparameters, the number of arguments can quickly grow, and the TOML file provides an easy way to collect and store different hyperparameter configurations. Every TOML ArgumentParser has a `toml` argument defined that we can pass using the following command-line syntax:\n\n```bash\npython experiment.py --toml \"example.toml\"\n```\n\nThis will replace the default values from the ArgumentParser with the TOML values.\n\n### 🐍 Extended Example\n\nTOML files have the ability to separate arguments into different sections (called `tables`), which are represented by nested dictionaries:\n\n```toml\n# This is a TOML File\n\n# Parameters without a prededing [] are not part of a table (called root-table)\nfoo = 10\nbar = \"hello\"\n\n# These arguments are part of the table [general]\n[general]\nfoo = 20\n\n# These arguments are part of the table [root]\n[root]\nbar = \"hey\"\n```\n\nIf we would load this TOML file as usual this would return a dict `{\"foo\": 10, \"bar\": \"hello\", \"general\": {\"foo\": 20}, \"root\" : {\"bar\": \"hey\"}}`. Note that `foo` and `bar` are overloaded and defined twice. To specify the values we wish to take each TOML ArgumentParser has two arguments defined:\n\n1. `table`\n2. `root-table`\n\nWe can use these directly from the command-line:\n\n```bash\npython experiment.py --toml \"example.toml\" --table \"general\"\n```\n\nHere the `root-table` is not defined. In this case the arguments at the top of the file without a table are taken and parsing would return the following dict `{\"foo\": 20, \"bar\": \"hello\"}`. Note that `table` arguments override arguments from the `root-table`. \n\nWe can also specify the root-table:\n\n```bash\npython experiment.py --toml \"example.toml\" --table \"general\" --root-table \"root\"\n```\n\nwhich would return the following dict `{\"foo: 20\", \"bar\": \"hey\"}` and override the arguments from the top of the TOML file.\n\nIn general, we have the following hierarchy of arguments:\n1. Arguments passed through the command line are selected over TOML\n           arguments, even if both are passed\n2. Arguments from the TOML file are preferred over the default arguments\n3. Arguments from the TOML with a section override the arguments without a section\n\nThis means that we can also override arguments in the TOML file from the command-line:\n\n```bash\npython experiment.py --toml \"example.toml\" --table \"general\" --foo 100\n```\n\n\n## 🌸 Contributing\n\nPlease have a look at the contribution guidlines in `Contributing.rst`.\n\n---\n\nRepository initiated with [fpgmaas/cookiecutter-poetry](https://github.com/fpgmaas/cookiecutter-poetry).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianmahner%2Ftomlparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflorianmahner%2Ftomlparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflorianmahner%2Ftomlparse/lists"}