Skip to main content

CLI for working with TOML files. Pronounced "tom clee."

Project description

tomcli

builds.sr.ht status

copr build status (gotmax23/tomcli)

copr build status (gotmax23/tomcli-dev)

CLI for working with TOML files. Pronounced "tom clee."

Links

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-list
	Return a newline separated list

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 lists

Modify lists within a TOML file

Remove all values that match a Python regex:

NOTE: The regex must match the entire string

$ tomcli-set pyproject.toml lists delitem \
    'project.classifiers' 'Programming Language :: Python.*'

Remove all values that match an fnmatch-style pattern:

$ tomcli-set pyproject.toml lists 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 lists 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 lists 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomcli-0.7.0.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

tomcli-0.7.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file tomcli-0.7.0.tar.gz.

File metadata

  • Download URL: tomcli-0.7.0.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for tomcli-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f4b761a341827b8d85cdd7952a8f86c2f22ec8e50f1f9c64789b7bfe5326399c
MD5 980cb794bdd3ad6e44d7d86c2e382560
BLAKE2b-256 5c3f591bce2b0d865bac7178ed7b074ede4b11a1ccec12b6b1eecea93f7ffd2d

See more details on using hashes here.

File details

Details for the file tomcli-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: tomcli-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for tomcli-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 169cd5cb76da333c2a8a2bf65684eadfbb739541ebaea3b54ec3d2b5e2a9c473
MD5 dbf2016ebc45e1e6b79be6f88e378d90
BLAKE2b-256 dd8b11f753c8445d104ce82a2746c3a6734c41437bf6837b1270dd6b204bcd20

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page