Metadata-Version: 2.1
Name: cargparse
Version: 0.0.2
Summary: Configuration file parsing with argparse.
Author: Eric DeMattos
License: MIT License
        
        Copyright (c) 2022 Eric DeMattos
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/edemattos/cargparse
Project-URL: Bug Tracker, https://github.com/edemattos/cargparse/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# cargparse :blue_car:

A lightweight library to parse configuration files using `argparse`.

- Robust type validation with `argparse`
- Supports nested arguments with recursive calls to `argparse`
- No syntax to learn, just use `argparse`!! :rocket:

Currently supports `yaml`/`yml` and `json` files. `ini`, `toml`,
and others are under development.

Contributions welcome! :handshake:

![python](https://img.shields.io/pypi/pyversions/cargparse)
![pypi version](https://img.shields.io/pypi/v/cargparse)
![license](https://img.shields.io/pypi/l/cargparse)
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Installation

```bash
pip install cargparse
```

## Usage

Given  `config.yaml`...

```yaml
text: hello world
decimal: 0.5
boolean: False
```

...your script might look like this...

```python
import argparse
import cargparse

parser = argparse.ArgumentParser()
parser.add_argument('--text', type=str)
parser.add_argument('--decimal', type=float)
parser.add_argument('--boolean', type=lambda x: eval(x))
args = cargparse.YAML(parser=parser, filename='config.yaml')
```

...which returns a `Namespace` object, just like `ArgumentParser.parse_args()`!

```bash
>> args
Namespace(text='hello world', decimal=0.5, boolean=False)
>> args.text
'hello world'
>> type(args.decimal)
<class 'float'>
```

:boom: Nested dictionaries are `Namespace` objects, too!
