All Projects → pappasam → toml-sort

pappasam / toml-sort

Licence: MIT License
Toml sorting library

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to toml-sort

Hugo Elasticsearch
Generate Elasticsearch indexes for Hugo static sites by parsing front matter
Stars: ✭ 19 (-38.71%)
Mutual labels:  toml, command-line-tool
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (+306.45%)
Mutual labels:  command-line-tool, command-line-parser
config-cpp
C++ Configuration management library inspired by the Viper package for golang.
Stars: ✭ 21 (-32.26%)
Mutual labels:  toml, command-line-parser
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (+1258.06%)
Mutual labels:  toml, command-line-tool
Taplo
A TOML toolkit written in Rust
Stars: ✭ 136 (+338.71%)
Mutual labels:  toml, formatter
Rq
Record Query - A tool for doing record analysis and transformation
Stars: ✭ 1,808 (+5732.26%)
Mutual labels:  toml, command-line-tool
minimist2
TypeScript/JavaScript ES6 rewrite of popular Minimist argument parser
Stars: ✭ 20 (-35.48%)
Mutual labels:  command-line-tool, command-line-parser
liszt
Save snippets of information quickly through the command line
Stars: ✭ 15 (-51.61%)
Mutual labels:  command-line-tool
clang-format-editor
Clang-Format Editor is a tool that helps you find the best Clang-Format Style for your C++, C#, Java, JavaScript, and Objective-C code.
Stars: ✭ 15 (-51.61%)
Mutual labels:  formatter
mdformat
CommonMark compliant Markdown formatter
Stars: ✭ 90 (+190.32%)
Mutual labels:  formatter
sample
Produce a sample of lines from files.
Stars: ✭ 17 (-45.16%)
Mutual labels:  command-line-tool
doing-cli
CLI tool to simplify the development workflow on azure devops
Stars: ✭ 19 (-38.71%)
Mutual labels:  command-line-tool
kirai
String formatting library for Java, Android, Web and Unix Terminal
Stars: ✭ 69 (+122.58%)
Mutual labels:  formatter
Code2HTML
JavaFX tool for converting source code to styled HTML
Stars: ✭ 26 (-16.13%)
Mutual labels:  formatter
chrome-webstore-manager
https://www.npmjs.com/package/chrome-webstore-manager
Stars: ✭ 32 (+3.23%)
Mutual labels:  command-line-tool
formatting
源码格式自动化调整工具
Stars: ✭ 37 (+19.35%)
Mutual labels:  formatter
kernel-run
Run any Jupyter notebook instantly using Kaggle kernels
Stars: ✭ 59 (+90.32%)
Mutual labels:  command-line-tool
Data-Structures-and-Algorithms
Data Structures and Algorithms implementation in Python
Stars: ✭ 31 (+0%)
Mutual labels:  sorting
pretty-remarkable
Plugin for prettifying markdown with https://github.com/jonschlinkert/remarkable using custom renderer rules.
Stars: ✭ 22 (-29.03%)
Mutual labels:  formatter
flynt-cli
CLI tool for the WordPress Flynt framework
Stars: ✭ 15 (-51.61%)
Mutual labels:  command-line-tool

toml-sort

pypi-version license python-versions image-pypi-downloads readthedocs-status

A command line utility to sort and format your toml files. Requires Python 3.6+.

Read the latest documentation here: https://toml-sort.readthedocs.io/en/latest/

Installation

# With pip
pip install toml-sort

# With poetry
poetry add --dev toml-sort

Motivation

This library sorts TOML files, providing the following features:

  • Sort tables and Arrays of Tables (AoT)
  • Option to sort non-tables / non-AoT's, or not
  • Preserve inline comments
  • Option to preserve top-level document comments, or not
  • Standardize whitespace and indentation

I wrote this library/application because I couldn't find any "good" sorting utilities for TOML files. Now, I use this as part of my daily workflow. Hopefully it helps you too!

Command line usage

This project can be used as either a command line utility or a Python library. Read the docs for an overview of its library capabilities. For command line usage, see below:

$ toml-sort --help
Usage: toml-sort [OPTIONS] [FILENAMES]...

  Sort toml file FILENAME(s), writing to file(s) or stdout (default)

  FILENAME a filepath or standard input (-)

  Examples (non-exhaustive list):
    Stdin -> Stdout : cat input.toml | toml-sort
    Disk -> Disk    : toml-sort -o output.toml input.toml
    Linting         : toml-sort --check input.toml input2.toml input3.toml
    Inplace Disk    : toml-sort --in-place input.toml input2.toml

Options:
  -o, --output PATH  The output filepath. Choose stdout with '-' (the
                     default).

  -a, --all          Sort all keys. Default is to only sort non-inline 'tables
                     and arrays of tables'.

  -i, --in-place     Makes changes to the original input file. Note: you
                     cannot redirect from a file to itself in Bash. POSIX
                     shells process redirections first, then execute the
                     command.

  --no-header        Do not keep a document's leading comments.
  --check            Check if an original file is changed by the formatter.
                     Return code 0 means it would not change. Return code 1
                     means it would change.

  -I, --ignore-case  When sorting, ignore case.
  --version          Show the version and exit.
  --help             Show this message and exit.

Example

The following example shows the input, and output, from the CLI with default options.

Unformatted, unsorted input

# My great TOML example

  title = "The example"

[[a-section.hello]]
ports = [ 8001, 8001, 8002 ]
dob = 1979-05-27T07:32:00Z # First class dates? Why not?



  [b-section]
  date = "2018"
  name = "Richard Stallman"

[[a-section.hello]]
ports = [ 80 ]
dob = 1920-05-27T07:32:00Z # Another date!

                          [a-section]
                          date = "2019"
                          name = "Samuel Roeca"

Formatted, sorted output

# My great TOML example

title = "The example"

[a-section]
date = "2019"
name = "Samuel Roeca"

[[a-section.hello]]
ports = [ 8001, 8001, 8002 ]
dob = 1979-05-27T07:32:00Z # First class dates? Why not?

[[a-section.hello]]
ports = [ 80 ]
dob = 1920-05-27T07:32:00Z # Another date!

[b-section]
date = "2018"
name = "Richard Stallman"

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, [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].