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
-
Clone the repository (if applicable):
git clone https://github.com/your-username/jsontoggle.git cd jsontoggle
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies: Using
uv(recommended):uv syncOr 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
tto 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
twill restore it to the JSON file using the saved value fromtoggles/.
- If the node is present, it will be removed from the JSON file, and its original value will be saved in the
Quitting the TUI
- Press
qto quit the application.
Example Workflow
-
Start with a demo file:
jsontoggle start --demo
-
Navigate to
featureFlags.darkMode. -
Press
tto toggle outdarkMode. You'll see it disappear from the main JSON structure, and a message indicating it's been toggled out. -
The
toggles/directory will now contain a file likefeatureFlags_darkMode.jsonwith the original value (false). -
Quit the application (
q). -
Re-launch with the
demo.jsonfile.jsontoggle start demo.json
You'll notice
featureFlags.darkModeis still toggled out. -
Navigate to the
featureFlags.darkMode (Toggled out)node. -
Press
tagain to revert the toggle. ThedarkModenode will reappear in the JSON, and its toggle file will be removed. -
Quit the application.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
099c3817e6e2ba1ad1464539de784bd56bb26e6be895e2bc6b200a0c48762916
|
|
| MD5 |
bf862072aa1154d79d92e37ebab73c1a
|
|
| BLAKE2b-256 |
ef128e5adf52273ab396d2f301fa9ac702af6ade4cfd2b5d578b853d4dfa1cce
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5fc26ec276e0032d21f765f079e4b68c9b1eaf6dd97357808b013a361a128a3
|
|
| MD5 |
94f8e76fcce30bd7262881a78ca05330
|
|
| BLAKE2b-256 |
d9a3ea4a7b63a3f06f01c71fce12f7e9c24c0edc0020516ff72e88cf206df3a0
|