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
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,38 @@
# <br><b>Changelog</b><br>


<span id="v1-9-5" />

## 25.01.2026 `v1.9.5`

* Add new class property `Console.encoding`, which returns the encoding used by the console (*e.g.* `utf-8`*,* `cp1252`*, …*).
* Add multiple new class properties to the `System` class:
- `is_linux` Whether the current OS is Linux or not.
- `is_mac` Whether the current OS is macOS or not.
- `is_unix` Whether the current OS is a Unix-like OS (Linux, macOS, BSD, …) or not.
- `hostname` The network hostname of the current machine.
- `username` The current user's username.
- `os_name` The name of the operating system (*e.g.* `Windows`*,* `Linux`*, …*).
- `os_version` The version of the operating system.
- `architecture` The CPU architecture (*e.g.* `x86_64`*,* `ARM`*, …*).
- `cpu_count` The number of CPU cores available.
- `python_version` The Python version string (*e.g.* `3.10.4`).
* Created a two new TypeAliases:
- `ArgParseConfig` Matches the command-line-parsing configuration of a single argument.
- `ArgParseConfigs` Matches the command-line-parsing configurations of multiple arguments, packed in a dictionary.
* Added a new attribute `flag` to the `ArgData` TypedDict and the `ArgResult` class, which contains the specific flag that was found or `None` for positional args.

**BREAKING CHANGES:**
* Rewrote `Console.get_args()` for a different parsing functionality:
- Flagged values are now too saved to lists, so now only the `values` attribute is used for all argument types.
- The results of parsed command-line arguments are also no longer differentiated between regular flagged arguments and positional `"before"`/`"after"` arguments.
- The param `allow_spaces` was removed, and therefore a new param `flag_value_sep` was added, which specifies the character/s used to separate flags from their values.<br>
This means, flags can new **only** receive values when the separator is present (*e.g.* `--flag=value` *or* `--flag = value`).
* Combined the custom TypedDict classes `ArgResultRegular` and `ArgResultPositional` into a single TypedDict class `ArgData`, which is now used for all parsed command-line arguments.
* Renamed the classes `Args` and `ArgResult` to `ParsedArgs` and `ParsedArgData`, to better describe their purpose.
* Renamed the attribute `is_positional` to `is_pos` everywhere, so its name isn't that long.


<span id="v1-9-4" />

## 06.01.2026 `v1.9.4`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "xulbux"
version = "1.9.4"
version = "1.9.5"
description = "A Python library to simplify common programming tasks."
readme = "README.md"
authors = [{ name = "XulbuX", email = "xulbux.real@gmail.com" }]
Expand Down
2 changes: 1 addition & 1 deletion src/xulbux/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__package_name__ = "xulbux"
__version__ = "1.9.4"
__version__ = "1.9.5"
__description__ = "A Python library to simplify common programming tasks."
__status__ = "Production/Stable"

Expand Down
21 changes: 11 additions & 10 deletions src/xulbux/base/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This module contains all custom type definitions used throughout the library.
"""

from typing import TYPE_CHECKING, Annotated, TypeAlias, TypedDict, Optional, Protocol, Union, Any
from typing import TYPE_CHECKING, Annotated, TypeAlias, TypedDict, Optional, Protocol, Literal, Union, Any
from pathlib import Path

# PREVENT CIRCULAR IMPORTS
Expand Down Expand Up @@ -70,6 +70,11 @@
AnyHexa: TypeAlias = Any
"""Generic type alias for hexadecimal color values in any supported format (type checking disabled)."""

ArgParseConfig: TypeAlias = Union[set[str], "ArgConfigWithDefault", Literal["before", "after"]]
"""Matches the command-line-parsing configuration of a single argument."""
ArgParseConfigs: TypeAlias = dict[str, ArgParseConfig]
"""Matches the command-line-parsing configurations of multiple arguments, packed in a dictionary."""

#
################################################## Sentinel ##################################################

Expand All @@ -83,21 +88,17 @@ class AllTextChars:


class ArgConfigWithDefault(TypedDict):
"""Configuration schema for a flagged CLI argument that has a specified default value."""
"""Configuration schema for a flagged command-line argument that has a specified default value."""
flags: set[str]
default: str


class ArgResultRegular(TypedDict):
"""Result schema for a parsed regular flagged CLI argument."""
exists: bool
value: Optional[str]


class ArgResultPositional(TypedDict):
"""Result schema for parsed positional (`"before"`/`"after"`) CLI arguments."""
class ArgData(TypedDict):
"""Schema for the resulting data of parsing a single command-line argument."""
exists: bool
is_pos: bool
values: list[str]
flag: Optional[str]


class MissingLibsMsgs(TypedDict):
Expand Down
Loading
Loading