Skip to content

Add --tree-only option to output folder structure without file contents#30

Merged
simone-viozzi merged 2 commits intomainfrom
copilot/fix-6
Jul 31, 2025
Merged

Add --tree-only option to output folder structure without file contents#30
simone-viozzi merged 2 commits intomainfrom
copilot/fix-6

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 29, 2025

This PR adds a new --tree-only command-line option that allows users to get only the directory structure tree without processing file contents. This addresses the need for a faster way to explore directory structures when file contents are not needed.

Changes

  • New CLI option: Added --tree-only flag that outputs only the folder structure
  • Performance optimization: Skips file content collection entirely when tree-only mode is enabled
  • Clean output: Tree-only mode outputs the raw tree structure without markdown formatting
  • Backward compatibility: All existing functionality remains unchanged

Usage

# Get only the directory tree structure
gpt-copy /path/to/directory --tree-only

# Works with all existing options
gpt-copy /path/to/directory --tree-only --exclude "tests/*"

# Output to file
gpt-copy /path/to/directory --tree-only -o structure.txt

Example Output

Normal mode:

# Folder Structure

project/
├── src/
│ └── main.py
└── docs/
└── README.md


## File: `src/main.py`
*(Relative Path: `src/main.py`)*

```python
1: print("Hello World")

**Tree-only mode:**

project/
├── src/
│ └── main.py
└── docs/
└── README.md


## Benefits

- **Faster execution** for large directories when only structure visualization is needed
- **Cleaner output** without markdown headers and file contents
- **Resource efficient** - doesn't read file contents or perform binary detection
- **Compatible** with existing filtering options (--include, --exclude, --force)

Fixes #6.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
Copilot AI changed the title [WIP] add option to get only the tree Add --tree-only option to output folder structure without file contents Jul 29, 2025
Copilot AI requested a review from simone-viozzi July 29, 2025 07:17
@simone-viozzi simone-viozzi marked this pull request as ready for review July 31, 2025 17:04
@simone-viozzi simone-viozzi merged commit a8fcf1e into main Jul 31, 2025
@simone-viozzi simone-viozzi deleted the copilot/fix-6 branch July 31, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants