History Module API Reference¶
This section documents the internals of the history
module in Bijux CLI.
bijux_cli.contracts.history ¶
Defines the contract for the command history management service.
This module specifies the HistoryProtocol
, a formal interface that any service responsible for recording, retrieving, and managing CLI command history events must implement.
HistoryProtocol ¶
Bases: Protocol
Defines the contract for command history management.
This interface specifies the methods for recording, retrieving, and managing command history events, including persistence and import/export functionality.
add ¶
add(
command: str,
*,
params: Sequence[str] | None = None,
success: bool | None = True,
return_code: int | None = 0,
duration_ms: float | None = None,
) -> None
Records a command execution event.
Parameters:
-
command
(str
) –The full command string (e.g., "status --verbose").
-
params
(Sequence[str] | None
, default:None
) –The raw argument vector as executed.
-
success
(bool | None
, default:True
) –True if the command was successful.
-
return_code
(int | None
, default:0
) –The integer exit code of the command.
-
duration_ms
(float | None
, default:None
) –Total execution time in milliseconds.
Returns:
-
None
(None
) –
Source code in src/bijux_cli/contracts/history.py
clear ¶
export ¶
Exports all history entries to a file.
Parameters:
-
path
(Path
) –The target file path, which will be overwritten.
Returns:
-
None
(None
) –
flush ¶
import_ ¶
Imports history entries from a file, replacing existing entries.
Parameters:
-
path
(Path
) –The source file path containing history data.
Returns:
-
None
(None
) –
list ¶
list(
*,
limit: int | None = 20,
group_by: str | None = None,
filter_cmd: str | None = None,
sort: str | None = None,
) -> list[dict[str, Any]]
Retrieves command history events.
Parameters:
-
limit
(int | None
, default:20
) –The maximum number of events to return.
-
group_by
(str | None
, default:None
) –A field name to group events by.
-
filter_cmd
(str | None
, default:None
) –A substring to filter commands by.
-
sort
(str | None
, default:None
) –A field name to sort the results by.
Returns:
-
list[dict[str, Any]]
–list[dict[str, Any]]: A list of history event dictionaries.