Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
fix: copy body to clipboard too
Browse files Browse the repository at this point in the history
if it exists
  • Loading branch information
lyz-code committed Sep 16, 2022
1 parent 42a4601 commit 7d908c0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/pynbox/entrypoints/cli.py
Expand Up @@ -167,12 +167,7 @@ def _process_element(
use_shortcuts=True,
).ask()
if choice == Choices.COPY:
subprocess.run( # nosec
["xclip", "-selection", "clipboard", "-i"],
input=element.description,
text=True,
check=True,
)
_copy_element(element)
else:
break

Expand Down Expand Up @@ -210,6 +205,20 @@ def _process_element(
return processed_elements


def _copy_element(element: "Element") -> None:
"""Copy an element to the clipboard."""
if element.body is None:
clipboard = element.description
else:
clipboard = f"{element.description}\n{element.body}"
subprocess.run( # nosec
["xclip", "-selection", "clipboard", "-i"],
input=clipboard,
text=True,
check=True,
)


@cli.command(hidden=True)
@click.pass_context
def null(ctx: Context) -> None:
Expand Down

0 comments on commit 7d908c0

Please sign in to comment.