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.1.tar.gz (5.1 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.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jsontoggle-0.1.1.tar.gz
Algorithm Hash digest
SHA256 db73270b8444d86636d86ab8b5563c3b0bc70d869e0ccbaa5cc079c6e58b184b
MD5 ee92cea7946cbabfa68d23fbff8fe34c
BLAKE2b-256 704648926809edf7dec8302dbdb53b8b0b6203e1dd9f2f90a95a1221af249f53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jsontoggle-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ccc3b64d428f29e13d12b20ba8152aa9c4dd18cf2e03ae1f6f208b4ca187fa2e
MD5 59d7c1e9173ba9e67a691e834979d838
BLAKE2b-256 53c5256118e03d98354197fde91bc2b3445bd3ac36f807e7ab5432bfb1515392

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