Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 1d4a9ee

Browse files
committed
feat: Upgrade command copied to clipboard
The upgrade command, which is suggested when the tool detects it is out of date, is also copied to the user's clipboard.
1 parent 5d36339 commit 1d4a9ee

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

gitcommit/updater.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from prompt_toolkit.formatted_text import FormattedText
55
from prompt_toolkit.styles import Style
66
from .ansi import ANSI as Ansi
7+
import pyperclip # pylint: disable=import-error
78

89

910
def get_github_tags():
@@ -36,6 +37,8 @@ def check_for_update():
3637

3738
if latest_tag_version != cur_version:
3839
Ansi.print_ok("There is an update available for conventional-commit.")
40+
upgrade_command = "pip install --upgrade conventional-commit"
41+
pyperclip.copy(upgrade_command)
3942

4043
style = Style.from_dict(
4144
{"green": "#a0d762 bold", "red": "#e67061 bold", "command": "#f78ae0 bold"}
@@ -46,8 +49,8 @@ def check_for_update():
4649
("class:red", cur_version),
4750
("", " → "),
4851
("class:green", latest_tag_version),
49-
("", "\nTry running: "),
50-
("class:command", "pip install --upgrade conventional-commit"),
52+
("", "\nAdded to your clipboard: "),
53+
("class:command", upgrade_command),
5154
]
5255
)
5356
print_formatted_text(text, style=style)

poetry.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ gitcommit = 'gitcommit.gitcommit:main'
2424
python = "^3.6"
2525
prompt_toolkit = "^2.0"
2626
requests = "^2.22"
27+
pyperclip = "^1.7"
2728

2829
[tool.poetry.dev-dependencies]
2930

0 commit comments

Comments
 (0)