Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Then pass `backend="blessed"` to `pick(...)`.

**pick** comes with a simple api:

>>> from pick import pick
>>> import pick
>>> # You can also use `from pick import pick` if you do not want to use cadule's magic: https://github.com/aisk/cadule

>>> title = 'Please choose your favorite programming language: '
>>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ keywords = ["terminal", "gui"]
requires-python = ">=3.8"

dependencies = [
"cadule>=0.0.1,<1.0.0",
"windows-curses>=2.2.0; platform_system=='Windows'",
]

Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ warn_unused_ignores = True

[mypy-blessed]
ignore_missing_imports = True

[mypy-cadule]
ignore_missing_imports = True
32 changes: 32 additions & 0 deletions src/pick/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from dataclasses import dataclass, field
from typing import Any, Container, Generic, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union

import cadule

from .backend import Backend
from .blessed_backend import BlessedBackend
from .curses_backend import CursesBackend
Expand All @@ -16,6 +18,7 @@
"Backend",
"CursesBackend",
"BlessedBackend",
"__call__",
"SYMBOL_CIRCLE_FILLED",
"SYMBOL_CIRCLE_EMPTY",
]
Expand Down Expand Up @@ -302,3 +305,32 @@ def pick(
backend,
)
return picker.start()


@cadule
def __call__(
options: Sequence[OPTION_T],
title: Optional[str] = None,
indicator: str = "*",
default_index: int = 0,
multiselect: bool = False,
min_selection_count: int = 0,
screen: Optional[curses.window] = None,
position: Position = Position(0, 0),
clear_screen: bool = True,
quit_keys: Optional[Union[Container[int], Iterable[int]]] = None,
backend: Union[str, Backend] = "curses",
):
return pick(
options,
title,
indicator,
default_index,
multiselect,
min_selection_count,
screen,
position,
clear_screen,
quit_keys,
backend,
)
11 changes: 11 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading