mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 09:15:57 +02:00
DRYer
This commit is contained in:
@@ -5,8 +5,9 @@ import re
|
||||
import sys
|
||||
from binascii import hexlify, unhexlify
|
||||
from contextlib import suppress
|
||||
from typing import Dict, Literal, Optional, Type
|
||||
from typing import Dict, Optional, Type, get_args
|
||||
|
||||
from kitty.conf.utils import OSNames, os_name
|
||||
from kitty.constants import appname, str_version
|
||||
from kitty.options.types import Options
|
||||
from kitty.terminfo import names
|
||||
@@ -229,11 +230,10 @@ class ClipboardControl(Query):
|
||||
@query
|
||||
class OSName(Query):
|
||||
name: str = 'os_name'
|
||||
help_text: str = 'The name of the OS the terminal is running on. Kitty supports values: linux, macos, bsd or unknown'
|
||||
help_text: str = f'The name of the OS the terminal is running on. Kitty returns values: {", ".join(sorted(get_args(OSNames)))}'
|
||||
|
||||
@staticmethod
|
||||
def get_result(opts: Options, window_id: int, os_window_id: int) -> Literal['macos', 'bsd', 'linux', 'unknown']:
|
||||
from kitty.conf.utils import os_name
|
||||
def get_result(opts: Options, window_id: int, os_window_id: int) -> OSNames:
|
||||
return os_name()
|
||||
|
||||
|
||||
|
||||
@@ -176,10 +176,10 @@ class CurrentlyParsing:
|
||||
|
||||
|
||||
currently_parsing = CurrentlyParsing()
|
||||
|
||||
OSNames = Literal['macos', 'bsd', 'linux', 'unknown']
|
||||
|
||||
@run_once
|
||||
def os_name() -> Literal['macos', 'bsd', 'linux', 'unknown']:
|
||||
def os_name() -> OSNames:
|
||||
if is_macos:
|
||||
return 'macos'
|
||||
if 'bsd' in _plat:
|
||||
|
||||
Reference in New Issue
Block a user