mirror of
https://github.com/kirill-markin/repo-to-text.git
synced 2025-12-06 03:22:23 -08:00
clipboard feature
This commit is contained in:
parent
a7d497f63a
commit
118da435cc
3 changed files with 17 additions and 2 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
- Generates a text representation of a directory's structure.
|
- Generates a text representation of a directory's structure.
|
||||||
- Includes the output of the `tree` command.
|
- Includes the output of the `tree` command.
|
||||||
- Saves the contents of each file, encapsulated in markdown code blocks.
|
- Saves the contents of each file, encapsulated in markdown code blocks.
|
||||||
|
- Copies the generated text representation to the clipboard for easy sharing.
|
||||||
- Easy to install and use via `pip` and Homebrew.
|
- Easy to install and use via `pip` and Homebrew.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
@ -32,12 +33,14 @@ brew install yourusername/repo-to-text
|
||||||
To install `repo-to-text` locally for development, follow these steps:
|
To install `repo-to-text` locally for development, follow these steps:
|
||||||
|
|
||||||
1. Clone the repository:
|
1. Clone the repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/yourusername/repo-to-text.git
|
git clone https://github.com/yourusername/repo-to-text.git
|
||||||
cd repo-to-text
|
cd repo-to-text
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install the package locally:
|
2. Install the package locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install -e .
|
pip install -e .
|
||||||
```
|
```
|
||||||
|
|
@ -50,7 +53,7 @@ After installation, you can use the `repo-to-text` command in your terminal. Nav
|
||||||
repo-to-text
|
repo-to-text
|
||||||
```
|
```
|
||||||
|
|
||||||
This will create a file named `repo_structure.txt` in the current directory with the text representation of the repository.
|
This will create a file named repo_snapshot.txt in the current directory with the text representation of the repository. The contents of this file will also be copied to your clipboard for easy sharing.
|
||||||
|
|
||||||
## Enabling Debug Logging
|
## Enabling Debug Logging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import pathspec
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import pyperclip
|
||||||
|
|
||||||
def setup_logging(debug=False):
|
def setup_logging(debug=False):
|
||||||
logging_level = logging.DEBUG if debug else logging.INFO
|
logging_level = logging.DEBUG if debug else logging.INFO
|
||||||
|
|
@ -80,7 +81,7 @@ def remove_empty_dirs(tree_output: str, path='.') -> str:
|
||||||
logging.debug('Empty directory removal complete')
|
logging.debug('Empty directory removal complete')
|
||||||
return '\n'.join(final_lines)
|
return '\n'.join(final_lines)
|
||||||
|
|
||||||
def save_repo_to_text(path='.') -> None:
|
def save_repo_to_text(path='.') -> str:
|
||||||
logging.debug(f'Starting to save repo structure to text for path: {path}')
|
logging.debug(f'Starting to save repo structure to text for path: {path}')
|
||||||
gitignore_spec = load_gitignore(path)
|
gitignore_spec = load_gitignore(path)
|
||||||
tree_structure = get_tree_structure(path, gitignore_spec)
|
tree_structure = get_tree_structure(path, gitignore_spec)
|
||||||
|
|
@ -123,6 +124,16 @@ def save_repo_to_text(path='.') -> None:
|
||||||
file.write('[Could not decode file contents]\n')
|
file.write('[Could not decode file contents]\n')
|
||||||
file.write('\n```\n')
|
file.write('\n```\n')
|
||||||
logging.debug('Repository contents written to file')
|
logging.debug('Repository contents written to file')
|
||||||
|
|
||||||
|
# Read the contents of the generated file
|
||||||
|
with open(output_file, 'r') as file:
|
||||||
|
repo_text = file.read()
|
||||||
|
|
||||||
|
# Copy the contents to the clipboard
|
||||||
|
pyperclip.copy(repo_text)
|
||||||
|
logging.debug('Repository structure and contents copied to clipboard')
|
||||||
|
|
||||||
|
return output_file
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Convert repository structure and contents to text')
|
parser = argparse.ArgumentParser(description='Convert repository structure and contents to text')
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@ setuptools==70.0.0
|
||||||
pathspec==0.12.1
|
pathspec==0.12.1
|
||||||
pytest==8.2.2
|
pytest==8.2.2
|
||||||
argparse==1.4.0
|
argparse==1.4.0
|
||||||
|
pyperclip==1.8.2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue