From aa2087f1cd32192c15a340100bab000371c0adcc Mon Sep 17 00:00:00 2001 From: Kausheya2006 Date: Wed, 1 Oct 2025 13:17:23 +0530 Subject: [PATCH 1/3] Added new flag : -x to list commands exclusive to a platform --- README.md | 1 + tldr.py | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea0fdc9..97f8244 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ options: -p PLATFORM, --platform PLATFORM Override the operating system [android, freebsd, linux, netbsd, openbsd, osx, sunos, windows, common] -l, --list List all available commands for operating system + -x, --exclusive Use with --list and -p to list commands exclusive to the specfied platform -s SOURCE, --source SOURCE Override the default page source -c, --color Override color stripping diff --git a/tldr.py b/tldr.py index fb81560..35233a3 100755 --- a/tldr.py +++ b/tldr.py @@ -382,9 +382,21 @@ def get_page( COMMAND_SPLIT_REGEX = re.compile(r'(?P{{.+?}*}})') PARAM_REGEX = re.compile(r'(?:{{)(?P.+?)(?:}})') +def get_exclusive_commands(platforms: List[str], language: Optional[List[str]] = None) -> List[str]: + + common_commands = set(get_commands(['common'], language)) + exclusive_commands = set() + + for platform in platforms: + platform_commands = set(get_commands([platform], language)) + exclusive_commands.update(platform_commands - common_commands) + + return sorted(exclusive_commands) + def get_commands(platforms: Optional[List[str]] = None, - language: Optional[str] = None) -> List[str]: + language: Optional[str] = None, + exclusive: bool = False) -> List[str]: if platforms is None: platforms = get_platform_list() @@ -394,6 +406,10 @@ def get_commands(platforms: Optional[List[str]] = None, languages = get_language_list() commands = [] + + if exclusive: + return get_exclusive_commands(platforms, language); + if get_cache_dir().exists(): for platform in platforms: for language in languages: @@ -610,6 +626,11 @@ def create_parser() -> ArgumentParser: action='store_true', help="List all available commands for operating system") + parser.add_argument('-x', '--exclusive', + default=False, + action='store_true', + help="Use with --list and -p to list commands exclusive to the specfied platform") + parser.add_argument('-s', '--source', default=PAGES_SOURCE_LOCATION, type=str, @@ -714,7 +735,8 @@ def main() -> None: parser.print_help(sys.stderr) sys.exit(1) if options.list: - print('\n'.join(get_commands(options.platform, options.language))) + print('\n'.join(get_commands(options.platform, options.language, options.exclusive))) + elif options.render: for command in options.command: file_path = Path(command) From eabcd81065c8b3e224c9471dca251037b30626b1 Mon Sep 17 00:00:00 2001 From: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> Date: Tue, 23 Dec 2025 06:23:39 +0100 Subject: [PATCH 2/3] Update README.md Co-authored-by: Managor <42655600+Managor@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 97f8244..3ed6c90 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ options: -p PLATFORM, --platform PLATFORM Override the operating system [android, freebsd, linux, netbsd, openbsd, osx, sunos, windows, common] -l, --list List all available commands for operating system - -x, --exclusive Use with --list and -p to list commands exclusive to the specfied platform + -x, --exclusive Use with --list and --platform to list commands exclusive to the specfied platform -s SOURCE, --source SOURCE Override the default page source -c, --color Override color stripping From 6a7bcebb265af63ca3c635ed7cea97da4e24bb05 Mon Sep 17 00:00:00 2001 From: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> Date: Tue, 23 Dec 2025 06:23:47 +0100 Subject: [PATCH 3/3] Update tldr.py --- tldr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tldr.py b/tldr.py index 35233a3..7e46a6d 100755 --- a/tldr.py +++ b/tldr.py @@ -629,7 +629,7 @@ def create_parser() -> ArgumentParser: parser.add_argument('-x', '--exclusive', default=False, action='store_true', - help="Use with --list and -p to list commands exclusive to the specfied platform") + help="Use with --list and --platform to list commands exclusive to the specfied platform") parser.add_argument('-s', '--source', default=PAGES_SOURCE_LOCATION,