CLI for working with TOML files. Pronounced "tom clee."
Project description
tomcli
CLI for working with TOML files. Pronounced "tom clee."
Links
- tomcli docsite
- tomcli project hub
- tomcli git.sr.ht repo
- tomcli tracker
- tomcli mailing list (~gotmax/tomcli@lists.sr.ht)
Examples
tomcli-get
Query TOML files
Print a TOML table:
$ tomcli-get pyproject.toml build-system
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
Get a newline-separated list of strings:
$ tomcli-get pyproject.toml --formatter newline-list project.dependencies
click
importlib_metadata; python_version<'3.11'
List all available formatters for use
with tomcli-get -F
/ tomcli-get --formatter
:
$ tomcli-formatters
default
Use the `toml` formatter if the object is a Mapping and fall back to
`string`.
json
Return the JSON representation of the object
newline-keys
Return a newline-separated list of Mapping keys
newline-list
Return a newline separated list
newline-values
Return a newline-separated list of Mapping values
string
Print the Python str() representation of the object
toml
Return the TOML mapping of the object
tomcli-set
Modify TOML files
Delete a TOML value:
$ tomcli-set pyproject.toml del 'project.dependencies'
Set a value to true
or false
:
$ tomcli-set pyproject.toml true 'tool.mypy.check_untyped_defs'
$ tomcli-set pyproject.toml false 'tool.mypy.check_untyped_defs'
Set a float
or int
value:
$ tomcli-set pyproject.toml float 'tool.coverage.run.fail_under' '90.0'
$ tomcli-set pyproject.toml int 'tool.coverage.run.fail_under' '90'
Set a string value:
$ tomcli-set pyproject.toml str 'project.readme' 'README.rst'
tomcli-get arrays
Modify arrays within a TOML file
Remove all values that match a Python regex:
NOTE: The regex must match the entire string
$ tomcli-set pyproject.toml arrays delitem \
'project.classifiers' 'Programming Language :: Python.*'
Remove all values that match an fnmatch-style pattern:
$ tomcli-set pyproject.toml arrays delitem --type fnmatch \
'project.optional-dependencies.dev' '*cov*'
Replace values that match a Python regex:
NOTE: The regex must match the entire string
$ tomcli-set pyproject.toml arrays replace \
'project.optional-dependencies.test' '(.+)==(.+)' '\1>=\2'
Create a list of strings:
## Create the new file
$ touch plays.toml
## Automatically creates the "Romeo and Juliet" table
$ tomcli-set plays.toml arrays str \
'"Romeo and Juliet".characters' 'Romeo' 'Juliet' 'Mercuitio' 'Nurse'
Contributing
See CONTRIBUTING.md.
License
This repository is licensed under
SPDX-License-Identifer: MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tomcli-0.8.0.tar.gz
.
File metadata
- Download URL: tomcli-0.8.0.tar.gz
- Upload date:
- Size: 31.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34fc1e498437d6de8edbbbc16234fc549115c7299b4b8a9204db27096f78172d |
|
MD5 | c54a12576c23251c201154dceb8f8bb5 |
|
BLAKE2b-256 | 0ec46cc6c7a5325c3e47f10758adce18ce2297c960885052a005db65a1c2e422 |
File details
Details for the file tomcli-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: tomcli-0.8.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cc6b7adb2f457005442189af3cda88d455d38314a87aa2f92a68be19e488bb6 |
|
MD5 | 768bcaa99b2ab049df48da6b41e77962 |
|
BLAKE2b-256 | f7a0f711733806bb20a38a5cb76423c5424ec76ee52dd4514719d78f8f549337 |