mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
Compare commits
4 commits
6a46c28a10
...
7bd91b677c
Author | SHA1 | Date | |
---|---|---|---|
7bd91b677c | |||
0036ca29c8 | |||
|
bf230c414e | ||
|
b0f7307999 |
1 changed files with 7 additions and 2 deletions
|
@ -13,7 +13,11 @@ def platform_not_supported_error() -> NoReturn:
|
||||||
raise Exception("platform '{}' is not supported!".format(sys.platform))
|
raise Exception("platform '{}' is not supported!".format(sys.platform))
|
||||||
|
|
||||||
|
|
||||||
def run_chooser(choices: Iterable[str], prompt: Optional[str] = None, async_read: bool = False) -> int:
|
def run_chooser(
|
||||||
|
choices: Iterable[str],
|
||||||
|
prompt: Optional[str] = None,
|
||||||
|
async_read: bool = False,
|
||||||
|
) -> int:
|
||||||
supports_result_index = True
|
supports_result_index = True
|
||||||
if os.isatty(sys.stderr.fileno()):
|
if os.isatty(sys.stderr.fileno()):
|
||||||
process_args = [
|
process_args = [
|
||||||
|
@ -41,7 +45,8 @@ def run_chooser(choices: Iterable[str], prompt: Optional[str] = None, async_read
|
||||||
|
|
||||||
with chooser_process.stdin as pipe:
|
with chooser_process.stdin as pipe:
|
||||||
for index, choice in enumerate(choices):
|
for index, choice in enumerate(choices):
|
||||||
if "\n" not in choice:
|
|
||||||
|
if "\n" in choice:
|
||||||
raise Exception("choices can only span a single line")
|
raise Exception("choices can only span a single line")
|
||||||
if not supports_result_index:
|
if not supports_result_index:
|
||||||
pipe.write(str(index).encode())
|
pipe.write(str(index).encode())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue