Metadata-Version: 2.1
Name: outcome-read-toml
Version: 2.0.2
Summary: A small utility to read keys from TOML files.
Home-page: https://github.com/outcome-co/read-toml-py
Author: Outcome Engineering
Author-email: engineering@outcome.co
Requires-Python: >=3.8.5,<3.9.0
Classifier: Programming Language :: Python :: 3
Requires-Dist: click (>=7.1.2,<8.0.0)
Requires-Dist: outcome-utils (>=4.12.5,<5.0.0)
Requires-Dist: toml (>=0.10.1,<0.11.0)
Project-URL: Documentation, https://github.com/outcome-co/read-toml-py#README
Project-URL: Repository, https://github.com/outcome-co/read-toml-py
Description-Content-Type: text/markdown

# read-toml-py
![ci-badge](https://github.com/outcome-co/read-toml-py/workflows/Release/badge.svg?branch=v2.0.2) ![version-badge](https://img.shields.io/badge/version-2.0.2-brightgreen)

A small utility to read keys from TOML files.

## Usage

### Installation

```sh
poetry add outcome-read-toml
```

### Usage

The utility reads the value specified by the key from the provided TOML file, and prints it to stdout.

The path parameter should be a '.' separated sequences of keys that correspond to a path in the TOML structure.

Example TOML file:

```toml
title = "My TOML file"

[info]
version = "1.0.1"

[tools.poetry]
version = "1.1.2"
files = ['a.py', 'b.py']
```

Read standard keys:

```sh
read-toml --path my_file.toml --key title 
# "My TOML file"

read-toml --path my_file.toml --key info.version
# "1.0.1"
```

Read arrays:

```sh
read-toml --path my_file.toml --key tools.poetry.files
# "a.py b.py"

read-toml --path my_file.toml[0] --key tools.poetry.files
# "a.py"
```

You can't read non-leaf keys:

```sh
read_toml.py --path my_file.toml --key tools
# KeyError
```

You can check if a key exists:

```sh
read-toml --path my_file.toml --key title --check-only 
# 1

read-toml --path my_file.toml --key unknown_key --check-only
# 0
```

## Development

Remember to run `./pre-commit.sh` when you clone the repository.

