Skip to main content

A CLI tool for toggling JSON nodes.

Project description

JSON Toggle

A CLI tool for interactively toggling JSON nodes on and off within a JSON file, storing the original values for easy restoration.

Features

  • Interactive TUI: Navigate and select JSON nodes using a Text User Interface (TUI).
  • Toggle Nodes: Easily remove a JSON node from the main file, storing its original value in a separate toggle file.
  • Revert Toggles: Restore a previously toggled-out node by reinserting its original value from the toggle file.
  • Persistent Toggles: Toggled nodes' states are maintained across sessions, allowing you to manage feature flags or configurations effectively.

Installation

Prerequisites

  • Python 3.8 or higher
  • uv (optional, for faster dependency management)

Steps

  1. Clone the repository (if applicable):

    git clone https://github.com/your-username/jsontoggle.git
    cd jsontoggle
    
  2. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate # On Windows: .venv\Scripts\activate
    
  3. Install dependencies: Using uv (recommended):

    uv sync
    

    Or using pip:

    pip install -e .
    

Usage

The jsontoggle tool provides a TUI for interacting with your JSON files.

Launching the TUI

You can launch the TUI with an existing JSON file or create a demo file.

With an existing JSON file:

jsontoggle start <path_to_json_file>

Example:

jsontoggle start my_config.json

With a demo JSON file:

This will create a demo.json file in your current directory and launch the TUI with it.

jsontoggle start --demo

Navigating the TUI

  • Use arrow keys (Up/Down) to navigate through the JSON tree.
  • Press Space or Right Arrow to expand/collapse nodes.

Toggling Nodes

  • Select a node you wish to toggle.
  • Press t to toggle the selected node.
    • If the node is present, it will be removed from the JSON file, and its original value will be saved in the toggles/ directory.
    • If the node was previously toggled out (and appears as "(Toggled out)"), pressing t will restore it to the JSON file using the saved value from toggles/.

Quitting the TUI

  • Press q to quit the application.

Example Workflow

  1. Start with a demo file:

    jsontoggle start --demo
    
  2. Navigate to featureFlags.darkMode.

  3. Press t to toggle out darkMode. You'll see it disappear from the main JSON structure, and a message indicating it's been toggled out.

  4. The toggles/ directory will now contain a file like featureFlags_darkMode.json with the original value (false).

  5. Quit the application (q).

  6. Re-launch with the demo.json file.

    jsontoggle start demo.json
    

    You'll notice featureFlags.darkMode is still toggled out.

  7. Navigate to the featureFlags.darkMode (Toggled out) node.

  8. Press t again to revert the toggle. The darkMode node will reappear in the JSON, and its toggle file will be removed.

  9. Quit the application.

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

jsontoggle-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

jsontoggle-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file jsontoggle-0.1.2.tar.gz.

File metadata

  • Download URL: jsontoggle-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for jsontoggle-0.1.2.tar.gz
Algorithm Hash digest
SHA256 099c3817e6e2ba1ad1464539de784bd56bb26e6be895e2bc6b200a0c48762916
MD5 bf862072aa1154d79d92e37ebab73c1a
BLAKE2b-256 ef128e5adf52273ab396d2f301fa9ac702af6ade4cfd2b5d578b853d4dfa1cce

See more details on using hashes here.

File details

Details for the file jsontoggle-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jsontoggle-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for jsontoggle-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b5fc26ec276e0032d21f765f079e4b68c9b1eaf6dd97357808b013a361a128a3
MD5 94f8e76fcce30bd7262881a78ca05330
BLAKE2b-256 d9a3ea4a7b63a3f06f01c71fce12f7e9c24c0edc0020516ff72e88cf206df3a0

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