tacklebox-cli 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tacklebox-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: A small collection of CLI utilities.
5
5
  Project-URL: Homepage, https://c.csw.im/cswimr/tacklebox
6
6
  Project-URL: Issues, https://c.csw.im/cswimr/tacklebox/issues
7
- Project-URL: Source Archive, https://c.csw.im/cswimr/tacklebox/archive/bd061b0360efe66956b1bfd3d7ec74b23cd84d67.tar.gz
7
+ Project-URL: Source Archive, https://c.csw.im/cswimr/tacklebox/archive/d62432a7c631e0b612f20744c68f03c88dbc5313.tar.gz
8
8
  Author-email: cswimr <seaswimmerthefsh@gmail.com>
9
9
  License-Expression: MIT
10
10
  License-File: LICENSE.md
@@ -20,14 +20,14 @@ Description-Content-Type: text/markdown
20
20
  [<img alt="Actions Status" src="https://c.csw.im/cswimr/tacklebox/badges/workflows/actions.yml/badge.svg?style=plastic">](https://c.csw.im/cswimr/tacklebox/actions?workflow=actions.yml)
21
21
  [<img alt="PyPI - Version" src="https://img.shields.io/pypi/v/tacklebox-cli?style=plastic">](https://pypi.org/project/tacklebox-cli/)
22
22
  [<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/tacklebox-cli?style=plastic">](https://pypi.org/project/tacklebox-cli/)
23
- [<img alt="PyPI - License" src="https://img.shields.io/pypi/l/tacklebox-cli?style=plastic">](https://c.csw.im/cswimr/tacklebox/src/tag/0.4.2/LICENSE.md)
23
+ [<img alt="PyPI - License" src="https://img.shields.io/pypi/l/tacklebox-cli?style=plastic">](https://c.csw.im/cswimr/tacklebox/src/tag/0.4.3/LICENSE.md)
24
24
  tacklebox-cli offers a suite of useful CLI tools.
25
25
 
26
26
  ## Usage
27
27
 
28
28
  ### tacklebox copy / paste
29
29
 
30
- Cross-platform clipboard management tool. Uses system tools such as `wl-copy` on Linux Wayland or `clip.exe` on Windows, and [OSC 52](https://www.reddit.com/r/vim/comments/k1ydpn/a_guide_on_how_to_copy_text_from_anywhere/) escape codes when **copying** over SSH or when no other tools are available. See [`copy_with_tooling()`](https://c.csw.im/cswimr/tacklebox/src/tag/0.4.2/tacklebox/commands/clipboard.py) for all supported tools.
30
+ Cross-platform clipboard management tool. Uses system tools such as `wl-copy` on Linux Wayland or `clip.exe` on Windows, and [OSC 52](https://www.reddit.com/r/vim/comments/k1ydpn/a_guide_on_how_to_copy_text_from_anywhere/) escape codes when **copying** over SSH or when no other tools are available. See [`copy_with_tooling()`](https://c.csw.im/cswimr/tacklebox/src/tag/0.4.3/tacklebox/commands/clipboard.py) for all supported tools.
31
31
 
32
32
  ```bash
33
33
  $ echo "a" | tacklebox copy --trim && tacklebox paste
@@ -7,7 +7,7 @@ from base64 import b64encode
7
7
  from enum import Enum
8
8
  from typing import Annotated, Literal
9
9
 
10
- from typer import Argument, Exit, Option, Typer, echo
10
+ from typer import Argument, Exit, Option, Typer
11
11
 
12
12
  from tacklebox.utils import get_environment, stderr, stdout
13
13
 
@@ -33,7 +33,7 @@ def _try_command(mode: ClipboardMode, cmd: list[str], verbose: bool = False, dat
33
33
  """
34
34
  if shutil.which(cmd[0]) is None:
35
35
  if verbose:
36
- echo(f"{cmd[0]} not found in PATH.", err=True)
36
+ stderr.print(f"{cmd[0]} not found in PATH.")
37
37
  return False, None
38
38
 
39
39
  if cmd[0] == "clip.exe":
@@ -45,20 +45,26 @@ def _try_command(mode: ClipboardMode, cmd: list[str], verbose: bool = False, dat
45
45
  result = subprocess.run(
46
46
  cmd,
47
47
  input=data.encode(encoder) if data else None,
48
- capture_output=True,
48
+ # in PASTE mode, we need stdout, but we don't care about it in COPY mode
49
+ # this fixes a bug where `wl-copy` sometimes hangs when stdout is piped
50
+ capture_output=True if mode == ClipboardMode.PASTE else False,
49
51
  env=get_environment(),
50
52
  timeout=30,
51
53
  )
52
54
  if result.returncode == 0:
53
55
  if verbose:
54
- echo(f"{mode.value} using {' '.join(cmd)}", err=True)
56
+ stderr.print(f"{mode.value} using {' '.join(cmd)}")
55
57
  return True, result.stdout.decode(encoder) if result.stdout else None
56
58
  except subprocess.TimeoutExpired:
57
59
  if verbose:
58
- echo(f"{cmd[0]} timed out", err=True)
60
+ stderr.print(
61
+ f"{cmd[0]} timed out",
62
+ )
59
63
  except OSError as e:
60
64
  if verbose:
61
- echo(f"{cmd[0]} execution failed: {e}", err=True)
65
+ stderr.print(
66
+ f"{cmd[0]} execution failed: {e}",
67
+ )
62
68
  return False, None
63
69
 
64
70
 
@@ -71,7 +77,6 @@ def use_tooling(
71
77
  - The content of the `command` argument.
72
78
  - If `mode == ClipboardMode.COPY`:
73
79
  - Linux (Wayland):
74
- - `wl-copy -o`
75
80
  - `wl-copy`
76
81
  - `copyq add -`
77
82
  - Linux (X11):
@@ -116,13 +121,10 @@ def use_tooling(
116
121
 
117
122
  tools: dict[ClipboardMode, dict[str, list[list[str]]]] = {
118
123
  ClipboardMode.COPY: {
119
- "wayland": [["wl-copy", "-o"], ["wl-copy"], ["copyq", "add", "-"]],
124
+ "wayland": [["wl-copy"], ["copyq", "add", "-"]],
120
125
  "x11": [["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"], ["copyq", "add", "-"]],
121
126
  "darwin": [["reattach-to-user-namespace", "pbcopy"], ["pbcopy"]],
122
- "windows": [
123
- ["win32yank.exe", "-i"],
124
- ["clip.exe"],
125
- ],
127
+ "windows": [["win32yank.exe", "-i"], ["clip.exe"]],
126
128
  },
127
129
  ClipboardMode.PASTE: {
128
130
  "wayland": [["wl-paste", "--no-newline"], ["copyq", "read", "0"]],
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.4.2'
22
- __version_tuple__ = version_tuple = (0, 4, 2)
21
+ __version__ = version = '0.4.3'
22
+ __version_tuple__ = version_tuple = (0, 4, 3)
23
23
 
24
24
  __commit_id__ = commit_id = None
File without changes
File without changes