Coverage for /home/runner/work/bijux-cli/bijux-cli/src/bijux_cli/commands/memory/__init__.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-19 23:36 +0000

1# SPDX-License-Identifier: MIT 

2# Copyright © 2025 Bijan Mousavi 

3 

4"""Defines the `memory` command group for the Bijux CLI. 

5 

6This module serves as the central entry point for managing the CLI's transient, 

7in-memory data store. It aggregates the various subcommands into a single 

8`Typer` application, creating the `bijux memory` command hierarchy. The data 

9in this store persists only for the lifetime of the application's parent process. 

10 

11The `memory` command, when run without a subcommand, provides a brief summary 

12of the memory store's state. 

13 

14The available subcommands are: 

15 * `set`: Sets a key-value pair. 

16 * `get`: Retrieves the value for a specific key. 

17 * `delete`: Removes a key-value pair. 

18 * `list`: Lists all defined keys. 

19 * `clear`: Removes all key-value pairs from the memory store. 

20 

21Exit codes for the subcommands generally follow this pattern: 

22 * `0`: Success. 

23 * `1`: An internal or unexpected error occurred (e.g., service unavailable). 

24 * `2`: An invalid argument was provided (e.g., bad format, invalid key). 

25 * `3`: An ASCII or encoding error was detected. 

26""" 

27 

28from __future__ import annotations 

29 

30import typer 

31 

32from bijux_cli.commands.memory.clear import clear_memory 

33from bijux_cli.commands.memory.delete import delete_memory 

34from bijux_cli.commands.memory.get import get_memory 

35from bijux_cli.commands.memory.list import list_memory 

36from bijux_cli.commands.memory.service import memory 

37from bijux_cli.commands.memory.set import set_memory 

38 

39typer.core.rich = None # type: ignore[attr-defined,assignment] 

40 

41memory_app = typer.Typer( # pytype: skip-file 

42 name="memory", 

43 help="Manage CLI memory.", 

44 rich_markup_mode=None, 

45 context_settings={"help_option_names": ["-h", "--help"]}, 

46 no_args_is_help=False, 

47) 

48 

49memory_app.callback(invoke_without_command=True)(memory) 

50 

51memory_app.command("set")(set_memory) 

52memory_app.command("get")(get_memory) 

53memory_app.command("delete")(delete_memory) 

54memory_app.command("clear")(clear_memory) 

55memory_app.command("list")(list_memory) 

56 

57__all__ = [ 

58 "memory_app", 

59]