Skip to content

Commit 9d15270

Browse files
Managorkbdharunsebastiaanspeck
authored
tldr: add a warning when a page is not available for current platform (#295)
Signed-off-by: Dharun Krishna K B <[email protected]> Co-authored-by: K.B.Dharun Krishna <[email protected]> Co-authored-by: Sebastiaan Speck <[email protected]>
1 parent 628a50f commit 9d15270

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ classifiers = [
4848
"Topic :: Utilities",
4949
]
5050
dependencies = [
51-
"colorama; sys_platform=='win32'",
51+
"colorama==0.4.6; sys_platform=='win32'",
5252
"shtab>=1.3.10",
5353
"termcolor",
5454
]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
termcolor
2-
colorama==0.4.6
2+
colorama==0.4.6; sys_platform=='win32'
33
shtab>=1.3.10

tldr.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ def main() -> None:
682682
display_option_length = "long"
683683
if options.short_options and options.long_options:
684684
display_option_length = "both"
685+
685686
if sys.platform == "win32":
686687
import colorama
687688
colorama.init(strip=options.color)
@@ -744,6 +745,17 @@ def main() -> None:
744745
).format(cmd=command))
745746
else:
746747
output(results[0][0], display_option_length, plain=options.markdown)
748+
749+
if results[0][1] not in (get_platform(), "common") and not options.platform:
750+
warning_suffix = (
751+
f": showing page from platform '{results[0][1]}', "
752+
f"because '{command}' does not exist in '{get_platform()}' and 'common'."
753+
)
754+
if options.markdown:
755+
print(f"warning{warning_suffix}")
756+
else:
757+
print(f"{colored('warning', 'yellow')}{warning_suffix}")
758+
747759
if results[1:]:
748760
platforms_str = [result[1] for result in results[1:]]
749761
are_multiple_platforms = len(platforms_str) > 1

0 commit comments

Comments
 (0)