From fdac1a85bc1562be94782852b9d491301c3694a9 Mon Sep 17 00:00:00 2001 From: ATURU GURU MADHAN REDDY Date: Mon, 26 Jan 2026 07:54:19 +0530 Subject: [PATCH] Added the feature of being able to use the cheatbox from anywhere of the file systems and also updated data folder to be able to be captured by the app folder and updated respective files to match the directory and also updated Documentation of Readme.md file for cleaner instructions. --- README.md | 36 +++++++++++++++++++++++++ cheatbox/data.py | 3 ++- {data => cheatbox/data}/bun.json | 0 {data => cheatbox/data}/docker.json | 0 {data => cheatbox/data}/kubernetes.json | 0 {data => cheatbox/data}/linux.json | 0 {data => cheatbox/data}/npm.json | 0 {data => cheatbox/data}/tmux.json | 0 cheatbox/display.py | 4 +-- cheatbox/main.py | 2 +- pyproject.toml | 3 +++ 11 files changed, 44 insertions(+), 4 deletions(-) rename {data => cheatbox/data}/bun.json (100%) rename {data => cheatbox/data}/docker.json (100%) rename {data => cheatbox/data}/kubernetes.json (100%) rename {data => cheatbox/data}/linux.json (100%) rename {data => cheatbox/data}/npm.json (100%) rename {data => cheatbox/data}/tmux.json (100%) diff --git a/README.md b/README.md index 9ca279b..23e7329 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,42 @@ uv run cheatbox `cheatbox` is inspired by the common cheatsheet posts in the Linkedin feed and also [BENTOBOX](https://www.google.com/search?q=bento). +## Running the Application Globally + +Install once, then run `cheatbox` from any directory. + +**Install** + +- pipx (recommended): + ```bash + pipx install cheatbox + ``` +- From a cloned repo: + ```bash + uv tool install . + ``` + +**Set PATH** + +- Windows (PowerShell): ensure `C:\Users\\.local\bin` is on PATH. One-time helper: + ```powershell + uv tool update-shell + ``` + Current session only: + ```powershell + $env:PATH = "C:\Users\\.local\bin;$env:PATH" + ``` +- Linux/macOS (bash/zsh): ensure `~/.local/bin` is on PATH: + ```bash + export PATH="$HOME/.local/bin:$PATH" + ``` + +**Run** + +```bash +cheatbox +``` + ## License GPL-3.0 diff --git a/cheatbox/data.py b/cheatbox/data.py index 1badbd6..7845086 100644 --- a/cheatbox/data.py +++ b/cheatbox/data.py @@ -5,7 +5,8 @@ class Data: def __init__(self): - self.base_dir = Path(__file__).parent.parent + # Keep data files alongside the package so installs include them + self.base_dir = Path(__file__).parent self.data_dir = self.base_dir / "data" self.domain: str = self.select_domain() diff --git a/data/bun.json b/cheatbox/data/bun.json similarity index 100% rename from data/bun.json rename to cheatbox/data/bun.json diff --git a/data/docker.json b/cheatbox/data/docker.json similarity index 100% rename from data/docker.json rename to cheatbox/data/docker.json diff --git a/data/kubernetes.json b/cheatbox/data/kubernetes.json similarity index 100% rename from data/kubernetes.json rename to cheatbox/data/kubernetes.json diff --git a/data/linux.json b/cheatbox/data/linux.json similarity index 100% rename from data/linux.json rename to cheatbox/data/linux.json diff --git a/data/npm.json b/cheatbox/data/npm.json similarity index 100% rename from data/npm.json rename to cheatbox/data/npm.json diff --git a/data/tmux.json b/cheatbox/data/tmux.json similarity index 100% rename from data/tmux.json rename to cheatbox/data/tmux.json diff --git a/cheatbox/display.py b/cheatbox/display.py index 693b2ed..95eaae4 100644 --- a/cheatbox/display.py +++ b/cheatbox/display.py @@ -64,8 +64,8 @@ def display_bento(self, json_data): logo_panel = self.get_ascii_panel(json_data, "LOGO") title_panel = self.get_ascii_panel(json_data, "TITLE") - - title_panel.subtitle = "CheatBox " + if title_panel: + title_panel.subtitle = "CheatBox " # Display the Logo and title if logo_panel or title_panel: diff --git a/cheatbox/main.py b/cheatbox/main.py index 56fbb07..39bb6c7 100644 --- a/cheatbox/main.py +++ b/cheatbox/main.py @@ -18,4 +18,4 @@ def main(ctx: typer.Context): list() if __name__ == "__main__": - app() + app() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 6aabcb9..8fabb14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,9 @@ cheatbox = "cheatbox.main:app" [tool.uv] package = true +[tool.hatch.build] +include = ["cheatbox", "images/*", "README.md", "CHEATSHEET.md"] + [build-system] requires = ["hatchling"] build-backend = "hatchling.build"