Skip to content

Commit

Permalink
add copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelmansuy committed Jun 28, 2024
1 parent f17aeb1 commit d5a7944
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
12 changes: 10 additions & 2 deletions code2prompt/write_output.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import click
from pathlib import Path
import pyperclip

def write_output(content, output_path):
"""
Writes the generated content to a file or prints it to the console.
Writes the generated content to a file or prints it to the console,
and copies the content to the clipboard.
Parameters:
- content (str): The content to be written or printed.
- content (str): The content to be written, printed, and copied.
- output_path (str): The path to the file where the content should be written.
If None, the content is printed to the console.
Expand All @@ -22,3 +24,9 @@ def write_output(content, output_path):
click.echo(f"Error writing to output file: {e}", err=True)
else:
click.echo(content)

# Copy content to clipboard
try:
pyperclip.copy(content)
except Exception as e:
click.echo(f"Error copying to clipboard: {e}", err=True)
12 changes: 11 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "code2prompt"
version = "0.6.0"
version = "0.6.1"
description = ""
authors = ["Raphael MANSUY <raphael.mansuy@gmail.com>"]
readme = "README.md"
Expand All @@ -12,6 +12,7 @@ click = "^8.1.7"
jinja2 = "^3.1.4"
prompt-toolkit = "^3.0.47"
tiktoken = "^0.7.0"
pyperclip = "^1.9.0"

[tool.poetry.scripts]
code2prompt = "code2prompt.main:create_markdown_file"
Expand Down

0 comments on commit d5a7944

Please sign in to comment.