Skip to content

Commit

Permalink
Add freebsd, netbsd, and openbsd platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
superatomic committed Nov 14, 2023
1 parent 2eaa535 commit ba4392f
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/tldr_man/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from click import Context


TLDR_PLATFORMS = 'android linux macos osx sunos windows'.split()
TLDR_PLATFORMS = 'android freebsd linux macos netbsd openbsd osx sunos windows'.split()


def get_page_sections(ctx: Context) -> list[str]:
Expand All @@ -40,14 +40,12 @@ def get_page_sections(ctx: Context) -> list[str]:

def get_current_platform() -> Optional[str]:
"""Get the correct tldr platform directory name from `sys.platform`."""
match sys.platform:
case 'darwin':
return 'osx'
case 'linux':
return 'linux'
case 'win32' | 'cygwin' | 'msys':
return 'windows'
case 'sunos5':
return 'sunos'
case _:
return None
platform = sys.platform
for platform_prefix in ['freebsd', 'linux', 'netbsd', 'openbsd', 'sunos']:
if platform.startswith(platform_prefix):
return platform_prefix
if platform == 'darwin':
return 'osx'
if platform in ['win32', 'cygwin', 'msys']:
return 'windows'
return None

0 comments on commit ba4392f

Please sign in to comment.