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

27 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-01-26 17:59 +0000

1# SPDX-License-Identifier: Apache-2.0 

2# Copyright © 2025 Bijan Mousavi 

3 

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

5 

6This module serves as the central entry point for all configuration management 

7functionality. It aggregates the various subcommands into a single `Typer` 

8application, creating the `bijux config` command hierarchy. 

9 

10The `config` command, when run without a subcommand, lists all current 

11key-value pairs. 

12 

13The available subcommands are: 

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

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

16 * `unset`: Removes a key-value pair. 

17 * `list`: Lists all defined configuration keys. 

18 * `clear`: Removes all key-value pairs from the configuration. 

19 * `load`: Replaces the current configuration with one from a file. 

20 * `reload`: Forces a reload of the configuration from its source file. 

21 * `export`: Writes the current configuration to a file or stdout. 

22 

23Exit codes for the subcommands generally follow this pattern: 

24 * `0`: Success. 

25 * `1`: An internal or unexpected error occurred. 

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

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

28""" 

29 

30from __future__ import annotations 

31 

32import typer 

33 

34from bijux_cli.cli.commands.config.clear import clear_config 

35from bijux_cli.cli.commands.config.export import export_config 

36from bijux_cli.cli.commands.config.get import get_config 

37from bijux_cli.cli.commands.config.list_cmd import list_config 

38from bijux_cli.cli.commands.config.load import load_config 

39from bijux_cli.cli.commands.config.reload import reload_config 

40from bijux_cli.cli.commands.config.service import config 

41from bijux_cli.cli.commands.config.set import set_config 

42from bijux_cli.cli.commands.config.unset import unset_config 

43from bijux_cli.core.runtime import AsyncTyper 

44 

45typer.core.rich = None # type: ignore[attr-defined] 

46 

47config_app = AsyncTyper( 

48 name="config", 

49 help="Manage CLI configuration.", 

50 rich_markup_mode=None, 

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

52 no_args_is_help=False, 

53) 

54 

55config_app.callback(invoke_without_command=True)(config) 

56 

57config_app.command("clear")(clear_config) 

58config_app.command("export")(export_config) 

59config_app.command("get")(get_config) 

60config_app.command("list")(list_config) 

61config_app.command("load")(load_config) 

62config_app.command("reload")(reload_config) 

63config_app.command("set")(set_config) 

64config_app.command("unset")(unset_config) 

65 

66 

67@config_app.command("import", hidden=True) 

68def import_config(*args, **kwargs) -> None: # type: ignore 

69 """Provides a backward-compatibility alias for the `config load` command. 

70 

71 This command is hidden from the main help text and delegates directly to 

72 `load_config`, forwarding all arguments. 

73 

74 Args: 

75 *args: Positional arguments to forward to `load_config`. 

76 **kwargs: Keyword arguments to forward to `load_config`. 

77 

78 Returns: 

79 None: 

80 """ 

81 return load_config(*args, **kwargs) 

82 

83 

84__all__ = [ 

85 "config_app", 

86]