Skip to content

Commit 83bf55f

Browse files
committed
update 1.8.0
1 parent 77f40c0 commit 83bf55f

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* new options for the param `find_args` from the method `Console.get_args()`:
1919
previously you could only input a dictionary with items like `"alias_name": ["-f", "--flag"]` that specify an arg's alias and the flags that correspond to it
2020
new, instead of flags, you can also once use the literal `"before"` and once `"after"`, which corresponds to all non-flagged values before or after all flagged values
21-
* changed the default `default_color` for all `Console` class input methods to `COLOR.ice`
21+
* changed the default `default_color` for all `Console` class input methods to `None`
2222
* the method `Console.restricted_input()` now returns an empty string instead of `None` if the user didn't input anything
2323
* fixed several small bugs for `Console.restricted_input()` regarding the ANSI formatting of the input prompt and the input text in the console
2424
* completely rewrote `Console.restricted_input()`, so now it's actually usable, and renamed it to just `Console.input()`

src/xulbux/console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ def input(
732732
default_color: Optional[Rgba | Hexa] = None,
733733
placeholder: Optional[str] = None,
734734
mask_char: Optional[str] = None,
735-
max_len: Optional[int] = None,
736735
min_len: Optional[int] = None,
736+
max_len: Optional[int] = None,
737737
allowed_chars: str = CHARS.all, #type: ignore[assignment]
738738
allow_paste: bool = True,
739739
validator: Optional[Callable[[str], Optional[str]]] = None,
@@ -746,8 +746,8 @@ def input(
746746
- `default_color` -⠀the default text color of the `prompt`
747747
- `placeholder` -⠀a placeholder text that is shown when the input is empty
748748
- `mask_char` -⠀if set, the input will be masked with this character
749-
- `max_len` -⠀the maximum length of the input
750-
- `min_len` -⠀the minimum length of the input
749+
- `min_len` -⠀the minimum length of the input (required to submit)
750+
- `max_len` -⠀the maximum length of the input (can't write further if reached)
751751
- `allowed_chars` -⠀a string of characters that are allowed to be inputted
752752
(default allows all characters)
753753
- `allow_paste` -⠀whether to allow pasting text into the input or not

tests/test_console.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ def test_console_size(mock_terminal_size):
119119
# LIST FLAG PROVIDED, DICT NOT PROVIDED (USES DEFAULT)
120120
(["script.py", "-l"], {"config": {"flags": ["-c", "--config"], "default": "prod.cfg"}, "log": ["-l"]
121121
}, {"config": {"exists": False, "value": "prod.cfg"}, "log": {"exists": True, "value": True}}),
122+
123+
# --- 'before' / 'after' SPECIAL CASES ---
124+
# 'before' SPECIAL CASE
125+
(["script.py", "arg1", "arg2", "-f", "file.txt"], {"before": "before", "file": ["-f"]},
126+
{"before": {"exists": True, "value": ["arg1", "arg2"]}, "file": {"exists": True, "value": "file.txt"}}),
127+
# 'after' SPECIAL CASE
128+
(["script.py", "-f", "file.txt", "arg1", "arg2"], {"after": "after", "file": ["-f"]},
129+
{"after": {"exists": True, "value": ["arg1", "arg2"]}, "file": {"exists": True, "value": "file.txt"}}),
122130
]
123131
)
124132
def test_get_args_no_spaces(monkeypatch, argv, find_args, expected_args_dict):

0 commit comments

Comments
 (0)