Skip to main content

Inspect ugly config files.

Project description

Conflook

A command line utiltiy for inspecting hard-to-read project config files such as json, yaml, and toml.

Usage

Usage: conflook [OPTIONS] FILE [KEYPATH]

  Show summarised structure or value at keypath.

Options:
  -v, --version        Show the version and exit.
  -h, --help           Show this message and exit.
  -l, --limit INTEGER  Default 10. Truncate output if more than `limit` lines.
                       If 0, there is no limit.

Keypath is a dot separated list of keys or indicies. For example, database.ports.2 would access the database table, then the ports array within that, then the 3rd item (at index 2) within that array. A consequence of this notation is that not all possible keys can be addressed.

If the value at the end of a valid keypath is a map-like object then it is shown as a list of keys followed by their type followed by a preview of their contents.

For example,

database, Table(4)
server         String(11) 192.168.1.1
ports          Array(3)   [8001, 8001, 8002]
connection_max Integer    5000
enabled        bool       True

A content preview attempts to be close to the real text content in the configuration file. For example, a YAML !!binary entry will not be decoded. Control sequences (eg newlines) in strings will be escaped.

Note that if no matching key is found in a keypath then conflook will show

  • The shortest key for which the given key is a prefix, or
  • The closest matching key as determined by difflib

For example,

conflook eg.toml data.prots

Gives

database.ports, Array(3)
[8001, 8001, 8002]

Install

Avaliable on PyPI.

  • Install with PIP.

    pip install conflook
    

    Run from command line

    conflook --help
    
  • OR, Add as development dependancy to PDM project.

    pdm add --dev conflook
    

    Run from pdm

    pdm run conflook --help
    

Develop

  1. Download this repository git clone ....

  2. Install PDM. Use PDM to install python dependancies with pdm sync.

    PDM will keep the versions of 3rd party libraries consistent with pdm.lock. The 3rd party libraries which this project depend on are listed in pyproject.toml along with other project settings used by the PyPI and exposing a command when installed.

  3. Enable pre-commit. Will run automatic checks for each git commit, as described in .pre-commit-config.yaml. Might need to run pdm run pre-commit install to setup. Pylint will check for the things specified in pylintrc.toml. Sometimes these checks can be ignored with a # pylint: disable= comment if they are too pedantic.

PDM should install an editable package. Make sure to put pdm run before any commands to make sure the correct Python interpreter is being used and the projects dependancies are avaliable. For example, pdm run conflook ... will run this utility, pdm run pre-commit run will manually run pre-commit checks, and pdm run python will start an interactive python session.

The folder eg/ contains example files.

TODO

  • search
  • grep friendly
    • line numbers
    • don't truncate
  • stats
  • extract sub object or array to file (or is this out of scope?)

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

conflook-0.1.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conflook-0.1.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file conflook-0.1.3.tar.gz.

File metadata

  • Download URL: conflook-0.1.3.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.4.8 CPython/3.11.5

File hashes

Hashes for conflook-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2f59ba7425e5c8f2f8c61583362c397f8b4fd897727ae330c4dfcdf087cc7033
MD5 4dce9be517e481538d76d6fc15bd20c4
BLAKE2b-256 50c47d5e3a34e3402943a6face4290e99d4938c94146e1e8eb9efa2012792fe8

See more details on using hashes here.

File details

Details for the file conflook-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: conflook-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.4.8 CPython/3.11.5

File hashes

Hashes for conflook-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc96ff6942a3f473e4f8857dd507d044a00257fb26510a8b77400c0dfb15578
MD5 f9c018526a41cc383ca65f0a52141d64
BLAKE2b-256 0678e3f1a1864e45452dc02766dfb05821fd02ff098a9b803dadfe505784fc94

See more details on using hashes here.

Supported by

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