diff --git a/cbrain_cli/data/readme.md b/cbrain_cli/data/readme.md new file mode 100644 index 0000000..ea4ca41 --- /dev/null +++ b/cbrain_cli/data/readme.md @@ -0,0 +1,34 @@ +# Welcome to the CBRAIN CLI Data Layer! 👋 + +This directory is the core engine connecting our command-line tools to **CBRAIN**—a powerful web-enabled platform built to manage large, distributed research datasets and mediate high-performance computing (HPC) tasks. + +Whenever the CLI needs to talk to CBRAIN's architecture (specifically the **BrainPortal** API), it happens right here. + +## How It Is Used 🛠️ + +Think of these Python modules as your direct bridge to CBRAIN's resources. They handle all the API calls, data fetching, and object modeling. If a user command needs to interact with the CBRAIN database, these modules do the heavy lifting. + +### The Modules at a Glance (with Example Commands!): + +* **`background_activities.py`**: Tracks backend jobs in progress (`cbrain background`). + * *Example:* `cbrain background list` +* **`data_providers.py`**: Connects to the systems storing your research data (`cbrain dataprovider`). + * *Example:* `cbrain dataprovider show 15` +* **`files.py`**: Manages data uploads, caching, and transfers across CBRAIN (`cbrain file`). + * *Example:* `cbrain file move --file-id 2 --dp-id 15` +* **`projects.py`**: Keeps user research organized (`cbrain project`). + * *Example:* `cbrain project switch 10` +* **`remote_resources.py`**: Interfaces with external network capabilities (`cbrain remote-resource`). + * *Example:* `cbrain remote-resource list` +* **`tags.py`**: Organizes and categorizes files and tasks (`cbrain tag`). + * *Example:* `cbrain tag create --name NewTag1 --user-id 2 --group-id 3` +* **`tasks.py`**: Orchestrates intensive compute jobs on remote HPCs (`cbrain task`). + * *Example:* `cbrain task show 2` +* **`tools.py` & `tool_configs.py`**: Manages the scientific tools available on CBRAIN (`cbrain tool` / `cbrain tool-config`). + * *Example:* `cbrain tool list` + +## How It Fits Together 🧩 + +**Data here, Display there.** + +This folder is strictly for fetching raw objects from the CBRAIN server. Once we pull the data, we hand it off to the `formatter/` directory, which takes those raw responses and turns them into clean, human-readable outputs for your terminal! diff --git a/cbrain_cli/formatter/readme.md b/cbrain_cli/formatter/readme.md new file mode 100644 index 0000000..d591632 --- /dev/null +++ b/cbrain_cli/formatter/readme.md @@ -0,0 +1,35 @@ +# Welcome to the CBRAIN CLI Formatter Layer! 🎨 + +This directory is all about **presentation**. Once the CLI fetches raw data objects from the CBRAIN backend (using the `data/` modules), it hands them over to these formatter scripts to make them look great in your terminal. + +These formatters are responsible for creating the clean tables, organized summaries, and human-readable text you see when you run a command. + +## How It Fits Together 🧩 + +**Data there, Display here.** + +While the `data/` directory handles backend API interactions, the `formatter/` directory focuses exclusively on presenting that info. Every `_fmt.py` file here perfectly matches a corresponding data module. For example, `tasks.py` gets the data, and `tasks_fmt.py` decides how to draw it on your screen! + +## What the Formatter Actually Does 🪄 + +Imagine you ask CBRAIN for a list of your files using `cbrain file list`. The raw data coming from the server is a dense machine-readable bundle filled with IDs, timestamps, and metadata. + +Instead of throwing that raw JSON at you, the formatter layer catches the data and turns it into a beautiful, easy-to-read table right in your terminal. Here is exactly what these scripts do: + +**The Raw Data (what `data/` gets):** +```json +{"id": 1024, "name": "my_mri_scan.nii.gz", "size": 47185920, "status": "synced"} +``` + +**The Formatted Output (what `formatter/` shows you):** +```text ++---------+----------------------+---------+-------------+ +| File ID | Name | Size | Status | ++---------+----------------------+---------+-------------+ +| 1024 | my_mri_scan.nii.gz | 45.0 MB | Synced | ++---------+----------------------+---------+-------------+ +``` + +*(Fun fact: We don't use heavy external libraries like `PrettyTable` or `Rich` for this! The CLI uses a custom-built, lightweight, dynamic table formatter powered completely by Python's built-in `textwrap` and `shutil` libraries. That means zero extra dependencies to slow you down!)* + +Every `_fmt.py` script in this folder is basically a tiny artist that knows exactly how to draw its specific type of data so it's perfectly readable for you!