Skip to content

Commit

Permalink
pyperclip not required
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-markin committed Oct 30, 2024
1 parent 42326ae commit ad36a75
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
17 changes: 12 additions & 5 deletions repo_to_text/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,23 @@ def save_repo_to_text(path='.', output_dir=None) -> str:
# Read the contents of the generated file
with open(output_file, 'r') as file:
repo_text = file.read()
# Copy the contents to the clipboard

# Try to copy to clipboard if pyperclip is installed
try:
import pyperclip
pyperclip.copy(repo_text)
logging.debug('Repository structure and contents copied to clipboard')
import importlib.util
if importlib.util.find_spec("pyperclip"):
import pyperclip
pyperclip.copy(repo_text)
logging.debug('Repository structure and contents copied to clipboard')
else:
print("Tip: Install 'pyperclip' package to enable automatic clipboard copying:")
print(" pip install pyperclip")
except Exception as e:
logging.warning('Could not copy to clipboard. You might be running this script over SSH or without clipboard support.')
logging.debug(f'Clipboard copy error: {e}')

print(f"[SUCCESS] Repository structure and contents successfully saved to file: \"./{output_file}\"")

return output_file

def create_default_settings_file():
Expand Down
11 changes: 5 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
setuptools==70.0.0
pathspec==0.12.1
pytest==8.2.2
argparse==1.4.0
pyperclip==1.8.2
PyYAML==6.0.1
setuptools>=70.0.0
pathspec>=0.12.1
pytest>=8.2.2
argparse>=1.4.0
PyYAML>=6.0.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='repo-to-text',
version='0.4.2',
version='0.4.3',
author='Kirill Markin',
author_email='[email protected]',
description='Convert a directory structure and its contents into a single text file, including the tree output and file contents in markdown code blocks. It may be useful to chat with LLM about your code.',
Expand Down

0 comments on commit ad36a75

Please sign in to comment.