34 lines
1.1 KiB
Diff
34 lines
1.1 KiB
Diff
diff --git a/daktari/result_printer.py b/daktari/result_printer.py
|
|
--- a/daktari/result_printer.py
|
|
+++ b/daktari/result_printer.py
|
|
@@ -1,7 +1,11 @@
|
|
import re
|
|
import textwrap
|
|
-import pyclip
|
|
from typing import Callable, Dict, Optional
|
|
|
|
+try:
|
|
+ import pyclip
|
|
+except ImportError:
|
|
+ pyclip = None
|
|
+
|
|
from colors import green, red, underline, yellow
|
|
|
|
from daktari.check import CheckResult, CheckStatus
|
|
@@ -58,10 +62,13 @@ def copy_to_clipboard(suggestion: Optional[str]):
|
|
command_regex = re.compile(r"\<cmd\>(.*?)\<\/cmd\>")
|
|
results = command_regex.findall(suggestion)
|
|
if len(results) > 0:
|
|
- try:
|
|
- pyclip.copy("\n".join(results))
|
|
+ if pyclip is not None:
|
|
+ try:
|
|
+ pyclip.copy("\n".join(results))
|
|
+ print("ⓘ Command copied to clipboard")
|
|
+ except pyclip.base.ClipboardSetupException:
|
|
print("ⓘ Clipboard not available")
|
|
+ else:
|
|
+ print("ⓘ Clipboard not available")
|
|
return
|
|
print("ⓘ No command available to copy to clipboard")
|