| Name | code-preview JSON |
| Version |
0.1.2
JSON |
| download |
| home_page | None |
| Summary | A universal CLI tool to preview uncommitted code changes with rich syntax highlighting — before you commit them. |
| upload_time | 2025-11-09 18:35:12 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.8 |
| license | None |
| keywords |
git
diff
cli
developer-tools
code
preview
terminal
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Code Preview
A universal CLI tool to preview **uncommitted code changes** with rich syntax highlighting — before you commit them.
It works with **any language** and **any Git repository**.
Quickly visualize what your next commit will look like — right in your terminal.
-----
## Features
* **Colored Diff Preview**: Additions (green), deletions (red), and context (gray).
* **Language-Agnostic**: Works for Java, Python, JavaScript, Scala, Go, etc.
* **Rich Terminal Output**: Powered by [Textualize Rich](https://github.com/Textualize/rich).
* **Git-Integrated**: Shows all unstaged and staged file changes.
* **No Commit Required**: Safe to preview changes locally anytime.
* **Extensible Design**: Add plugins or render to HTML in the future.
-----
## Example Output
Here is a preview of what changed in a Java file:
```diff
──────────────────────────────────────────────────────────────
a/src/main/java/com/example/App.java → b/src/main/java/com/example/App.java
@@ -14,6 +14,8 @@
public class App {
public static void main(String[] args) {
- System.out.println("Hello, world!");
+ System.out.println("Hello, Aryant!");
+ System.out.println("Code preview is working");
}
}
──────────────────────────────────────────────────────────────
```
-----
## Installation
### From PyPI (Recommended)
You can install `code-preview` using `pip`:
```sh
pip install code-preview
```
### From Source
If you want to install it from your local folder for development:
```sh
git clone https://github.com/Aryant-Tripathi/code-preview.git
cd code-preview
pip install -e .
```
-----
## Usage
### Preview All Unstaged Changes
Simply run the command in the root of your Git repository:
```sh
code-preview
```
### Preview Changes in a Specific Folder
You can limit the preview to a specific directory or file:
```sh
code-preview src/
```
### Run Directly Without Installation
You can also run the tool directly as a Python module:
```sh
python -m code_preview.cli
```
-----
## How It Works
1. Detects all files with uncommitted changes using **GitPython**.
2. Reads their last committed version (HEAD).
3. Compares against your local version using **difflib**.
4. Renders the diff with syntax highlighting via **Rich**.
-----
## Roadmap
* [ ] Auto-detect syntax for each file type (`.java`, `.py`, `.js`, etc.)
* [ ] Add `--html` mode for browser-based diff preview
* [ ] Add `--watch` mode for real-time change tracking
* [ ] Support for non-Git directories (via snapshots)
* [ ] VSCode/IntelliJ plugin integration
-----
## Development
Interested in contributing? Here's how to set up your environment.
### Setup Virtual Environment
```sh
python3 -m venv venv
source venv/bin/activate
```
### Install Dependencies
Install the project in "editable" mode:
```sh
pip install -e .
```
### Run Locally
Run the tool using the development entry point:
```sh
python -m code_preview.cli
```
### Project Structure
```text
code-preview/
├── src/
│ └── code_preview/
│ ├── __init__.py # Package initializer
│ ├── cli.py # Main CLI entry point (argparse)
│ ├── git_utils.py # Git interaction logic
│ ├── diff_renderer.py # Logic for rendering diffs with Rich
│ └── file_utils.py # File reading utilities
├── pyproject.toml # Build configuration (PEP 621)
├── setup.cfg # Package metadata
├── README.md
└── LICENSE
```
-----
## Publishing (For Maintainers)
1. **Build**:
```sh
python3 -m build
```
2. **Upload to TestPyPI**:
```sh
python3 -m twine upload --repository testpypi dist/*
```
3. **Test Install**:
```sh
pip install -i https://test.pypi.org/simple/ code-preview
```
4. **Publish to PyPI**:
```sh
python3 -m twine upload dist/*
```
-----
## Contributing
Contributions are welcome\! If you find this project useful:
* **Star it on GitHub** → [Aryant-Tripathi/code-preview](https://www.google.com/search?q=https://github.com/Aryant-Tripathi/code-preview)
* Open **issues** for feature requests or bugs
* Submit **pull requests** for enhancements
-----
## Acknowledgements
* [Rich](https://github.com/Textualize/rich) for beautiful terminal rendering
* [GitPython](https://github.com/gitpython-developers/GitPython) for Git integration
* Inspired by the need for more readable `git diff` previews for all developers
-----
## Author
**Aryant Tripathi**
* Software Engineer | Open Source Contributor | DSA Mentor
* **Email**: aryanttripathi@gmail.com
* **GitHub**: [@Aryant-Tripathi](https://github.com/Aryant-Tripathi)
* **LinkedIn**: [in/aryant-tripathi](https://www.linkedin.com/in/aryanttripathi/)
-----
## License
This project is licensed under the Apache-2.0 License — see the [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "code-preview",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "git, diff, cli, developer-tools, code, preview, terminal",
"author": null,
"author_email": "Aryant Tripathi <aryanttripathi@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/45/f8/1269a6b6011ad1a3c626e676ca3c14bc3756f954b7a7a997c9a1cefee60f/code_preview-0.1.2.tar.gz",
"platform": null,
"description": "# Code Preview\n\nA universal CLI tool to preview **uncommitted code changes** with rich syntax highlighting \u2014 before you commit them. \nIt works with **any language** and **any Git repository**.\n\nQuickly visualize what your next commit will look like \u2014 right in your terminal.\n\n-----\n\n## Features\n\n * **Colored Diff Preview**: Additions (green), deletions (red), and context (gray).\n * **Language-Agnostic**: Works for Java, Python, JavaScript, Scala, Go, etc.\n * **Rich Terminal Output**: Powered by [Textualize Rich](https://github.com/Textualize/rich).\n * **Git-Integrated**: Shows all unstaged and staged file changes.\n * **No Commit Required**: Safe to preview changes locally anytime.\n * **Extensible Design**: Add plugins or render to HTML in the future.\n\n-----\n\n## Example Output\n\nHere is a preview of what changed in a Java file:\n\n```diff\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\na/src/main/java/com/example/App.java \u2192 b/src/main/java/com/example/App.java\n\n@@ -14,6 +14,8 @@\n public class App {\n public static void main(String[] args) {\n- System.out.println(\"Hello, world!\");\n+ System.out.println(\"Hello, Aryant!\");\n+ System.out.println(\"Code preview is working\");\n }\n }\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n```\n\n-----\n\n## Installation\n\n### From PyPI (Recommended)\n\nYou can install `code-preview` using `pip`:\n\n```sh\npip install code-preview\n```\n\n### From Source\n\nIf you want to install it from your local folder for development:\n\n```sh\ngit clone https://github.com/Aryant-Tripathi/code-preview.git\ncd code-preview\npip install -e .\n```\n\n-----\n\n## Usage\n\n### Preview All Unstaged Changes\n\nSimply run the command in the root of your Git repository:\n\n```sh\ncode-preview\n```\n\n### Preview Changes in a Specific Folder\n\nYou can limit the preview to a specific directory or file:\n\n```sh\ncode-preview src/\n```\n\n### Run Directly Without Installation\n\nYou can also run the tool directly as a Python module:\n\n```sh\npython -m code_preview.cli\n```\n\n-----\n\n## How It Works\n\n1. Detects all files with uncommitted changes using **GitPython**.\n2. Reads their last committed version (HEAD).\n3. Compares against your local version using **difflib**.\n4. Renders the diff with syntax highlighting via **Rich**.\n\n-----\n\n## Roadmap\n\n * [ ] Auto-detect syntax for each file type (`.java`, `.py`, `.js`, etc.)\n * [ ] Add `--html` mode for browser-based diff preview\n * [ ] Add `--watch` mode for real-time change tracking\n * [ ] Support for non-Git directories (via snapshots)\n * [ ] VSCode/IntelliJ plugin integration\n\n-----\n\n## Development\n\nInterested in contributing? Here's how to set up your environment.\n\n### Setup Virtual Environment\n\n```sh\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n### Install Dependencies\n\nInstall the project in \"editable\" mode:\n\n```sh\npip install -e .\n```\n\n### Run Locally\n\nRun the tool using the development entry point:\n\n```sh\npython -m code_preview.cli\n```\n\n### Project Structure\n\n```text\ncode-preview/\n\u251c\u2500\u2500 src/\n\u2502 \u2514\u2500\u2500 code_preview/\n\u2502 \u251c\u2500\u2500 __init__.py # Package initializer\n\u2502 \u251c\u2500\u2500 cli.py # Main CLI entry point (argparse)\n\u2502 \u251c\u2500\u2500 git_utils.py # Git interaction logic\n\u2502 \u251c\u2500\u2500 diff_renderer.py # Logic for rendering diffs with Rich\n\u2502 \u2514\u2500\u2500 file_utils.py # File reading utilities\n\u251c\u2500\u2500 pyproject.toml # Build configuration (PEP 621)\n\u251c\u2500\u2500 setup.cfg # Package metadata\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 LICENSE\n```\n\n-----\n\n## Publishing (For Maintainers)\n\n1. **Build**:\n\n ```sh\n python3 -m build\n ```\n\n2. **Upload to TestPyPI**:\n\n ```sh\n python3 -m twine upload --repository testpypi dist/*\n ```\n\n3. **Test Install**:\n\n ```sh\n pip install -i https://test.pypi.org/simple/ code-preview\n ```\n\n4. **Publish to PyPI**:\n\n ```sh\n python3 -m twine upload dist/*\n ```\n\n-----\n\n## Contributing\n\nContributions are welcome\\! If you find this project useful:\n\n * **Star it on GitHub** \u2192 [Aryant-Tripathi/code-preview](https://www.google.com/search?q=https://github.com/Aryant-Tripathi/code-preview)\n * Open **issues** for feature requests or bugs\n * Submit **pull requests** for enhancements\n\n-----\n\n## Acknowledgements\n\n * [Rich](https://github.com/Textualize/rich) for beautiful terminal rendering\n * [GitPython](https://github.com/gitpython-developers/GitPython) for Git integration\n * Inspired by the need for more readable `git diff` previews for all developers\n\n-----\n\n## Author\n\n**Aryant Tripathi**\n\n * Software Engineer | Open Source Contributor | DSA Mentor\n * **Email**: aryanttripathi@gmail.com\n * **GitHub**: [@Aryant-Tripathi](https://github.com/Aryant-Tripathi)\n * **LinkedIn**: [in/aryant-tripathi](https://www.linkedin.com/in/aryanttripathi/)\n\n-----\n\n## License\n\nThis project is licensed under the Apache-2.0 License \u2014 see the [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": "A universal CLI tool to preview uncommitted code changes with rich syntax highlighting \u2014 before you commit them.",
"version": "0.1.2",
"project_urls": {
"Documentation": "https://github.com/Aryant-Tripathi/code-preview#readme",
"Homepage": "https://github.com/Aryant-Tripathi/code-preview",
"Issues": "https://github.com/Aryant-Tripathi/code-preview/issues",
"Repository": "https://github.com/Aryant-Tripathi/code-preview"
},
"split_keywords": [
"git",
" diff",
" cli",
" developer-tools",
" code",
" preview",
" terminal"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "952b83ffcfec370b4a4d793bafdc4bfbecb74106647b44214bd119e14bfe0eea",
"md5": "a6c9aef0b316fad565270e9066c661b3",
"sha256": "91b85555beb37d4913ed9ea8be85fd8f7ec2d1e305156432c589214c834a7d99"
},
"downloads": -1,
"filename": "code_preview-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a6c9aef0b316fad565270e9066c661b3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9563,
"upload_time": "2025-11-09T18:35:10",
"upload_time_iso_8601": "2025-11-09T18:35:10.849587Z",
"url": "https://files.pythonhosted.org/packages/95/2b/83ffcfec370b4a4d793bafdc4bfbecb74106647b44214bd119e14bfe0eea/code_preview-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "45f81269a6b6011ad1a3c626e676ca3c14bc3756f954b7a7a997c9a1cefee60f",
"md5": "7c7673f2b9386de19557fc378192faf4",
"sha256": "a04a00eb76620c1c8bce7e40a1a4b48d01c0da2e375ce6a4042bd9718f98bfd8"
},
"downloads": -1,
"filename": "code_preview-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "7c7673f2b9386de19557fc378192faf4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8995,
"upload_time": "2025-11-09T18:35:12",
"upload_time_iso_8601": "2025-11-09T18:35:12.193890Z",
"url": "https://files.pythonhosted.org/packages/45/f8/1269a6b6011ad1a3c626e676ca3c14bc3756f954b7a7a997c9a1cefee60f/code_preview-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-11-09 18:35:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Aryant-Tripathi",
"github_project": "code-preview#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "code-preview"
}