Skip to main content

Toml sorting library

Project description

toml-sort

A command line utility to sort your toml files. Requires Python 3.6 or greater.

Motivation

I wrote this library because I couldn't find any "good" sorting utilities for TOML files. This library strives to sort TOML files by providing the following features:

  • Preserve comments
  • Sort tables / arrays of Tables
  • Option to sort table keys, or not
  • Option to include "Super Table" headers, or not
  • Preserve whitespace / indentation (in progress)

Installation

pip install toml-sort

Usage

This project can be used as either a Python library or a command line utility. I will document the Python library interface in the future when it stabilizes. The command line interface should remain fairly stable.

Command line interface

Read from stdin, write to stdout:

cat input.toml | toml-sort

Read from file on disk, write to file on disk:

toml-sort -o output.toml input.toml

Read from file on disk, write to stdout

toml-sort input.toml

Read from stdin, write to file on disk

cat input.toml | toml-sort -o output.toml

Only sort the top-level tables / arrays of tables

cat input.toml | toml-sort -i
cat input.toml | toml-sort --ignore-non-tables

Include Super Tables

cat input.toml | toml-sort -s
cat input.toml | toml-sort --super-tables

Local Development

Local development for this project is quite simple.

Dependencies

Install the following tools manually.

Recommended

Set up development environment

make setup

Run Tests

make test

Written by

Samuel Roeca samuel.roeca@gmail.com

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

toml-sort-0.6.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

toml_sort-0.6.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file toml-sort-0.6.0.tar.gz.

File metadata

  • Download URL: toml-sort-0.6.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-55-generic

File hashes

Hashes for toml-sort-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4a7aa4631aead718b22df937151dc09d193cb50b860225cc0ebefbaba1c7667b
MD5 94edb4b35c3aef3c19b4280b5c3b3265
BLAKE2b-256 c0b4c826b63ad278da49636ed7fb6146f07f0f62e2c4c480abe03d4d975ddc5e

See more details on using hashes here.

File details

Details for the file toml_sort-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: toml_sort-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.3 Linux/4.15.0-55-generic

File hashes

Hashes for toml_sort-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bc63cda0726f0bdbd3dbb3fdbac03af89501ed0cd02cccf4a4c5f575e2f7654
MD5 fd75bff2aafcebbd83bc8eb29c5c4d3f
BLAKE2b-256 886cfade7b08023ace05f75bebd33aa8bf101509126689778f05786e361062e2

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