CLI Module (runex/cli.py) – Usage Examples

This document explains how to use the CLI tool and what to expect for each option. The CLI is built with Click and calls generate_prompt() from runex.core. Below are some practical usage scenarios with examples of the initial directory structure, sample .gitignore content (if applicable), and the expected output.


1. Default Mode (No Options)

Command:

runex my_project

Initial Directory Structure:

my_project/
├── .gitignore       # (Empty or irrelevant)
├── file.txt         # Contains some text
└── docs/
    └── manual.txt   # Contains manual content

.gitignore Content:
Assume it’s empty or does not ignore any files.

Expected Output (Plain Text):

Example snippet:

my_project/
├── file.txt
└── docs/
    └── manual.txt

# File: file.txt
# Path: file.txt
(Contents of file.txt)

# File: manual.txt
# Path: docs/manual.txt
(Contents of manual.txt)

2. Only Structure Mode (-s)

Command:

runex my_project -s

Initial Directory Structure:

(Same as above.)

.gitignore Content:
Not relevant for this example.

Expected Output (Plain Text):

Example snippet:

my_project/
├── file.txt
└── docs/
    └── manual.txt

3. JSON Mode (-oj)

Command:

runex my_project -oj

Initial Directory Structure:

(Same as above.)

.gitignore Content:
Not relevant.

Expected Output (JSON):

A JSON object with two main keys:

Example snippet:

{
  "structure": {
    "name": "my_project",
    "children": [
      { "name": ".gitignore" },
      { "name": "file.txt" },
      {
        "name": "docs",
        "children": [
          { "name": "manual.txt" }
        ]
      }
    ]
  },
  "files": [
    {
      "filename": "file.txt",
      "path": "file.txt",
      "content": "(Contents of file.txt)"
    },
    {
      "filename": "manual.txt",
      "path": "docs/manual.txt",
      "content": "(Contents of manual.txt)"
    }
  ]
}

4. Case-Insensitive Matching (-c)

Command:

runex my_project -c

Scenario:

Expected Output:


5. Relative Root Mode (-rr)

Command:

runex my_project -rr

Scenario:

Expected Output:

Example snippet:

./
├── file.txt
└── docs/
    └── manual.txt

6. Combining Options

Command:

runex my_project -s -oj -c -rr

Scenario:

Initial Directory Structure:

(Same as before.)

Expected Output (JSON Only Structure):

A JSON object with a "structure" key only (no "files" key). The root will be shown as ".".

Example snippet:

{
  "structure": {
    "name": ".",
    "children": [
      { "name": ".gitignore" },
      { "name": "file.txt" },
      {
        "name": "docs",
        "children": [
          { "name": "manual.txt" }
        ]
      }
    ]
  }
}

Summary

The CLI uses these options to call generate_prompt() from runex.core, ensuring that the project prompt strictly follows Git’s .gitignore rules. This flexible design lets developers choose the format and level of detail they need.