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

8 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"""Implements the `dev list-plugins` subcommand for the Bijux CLI. 

5 

6This module provides a developer-focused command to list all installed CLI 

7plugins. It delegates its core logic to the shared `handle_list_plugins` 

8utility, which scans the filesystem and returns a structured list. 

9 

10Output Contract: 

11 * Success: `{"plugins": [str, ...]}` 

12 * Verbose: Adds `{"python": str, "platform": str}` to the payload. 

13 * Error: `{"error": str, "code": int}` 

14 

15Exit Codes: 

16 * `0`: Success. 

17 * `1`: An error occurred while accessing the plugins directory. 

18 * `2`: An invalid flag was provided (e.g., bad format). 

19 * `3`: An ASCII or encoding error was detected in the environment. 

20""" 

21 

22from __future__ import annotations 

23 

24import typer 

25 

26from bijux_cli.commands.utilities import handle_list_plugins, validate_common_flags 

27from bijux_cli.core.constants import ( 

28 HELP_DEBUG, 

29 HELP_FORMAT, 

30 HELP_NO_PRETTY, 

31 HELP_QUIET, 

32 HELP_VERBOSE, 

33) 

34 

35 

36def dev_list_plugins( 

37 quiet: bool = typer.Option(False, "-q", "--quiet", help=HELP_QUIET), 

38 verbose: bool = typer.Option(False, "-v", "--verbose", help=HELP_VERBOSE), 

39 fmt: str = typer.Option("json", "-f", "--format", help=HELP_FORMAT), 

40 pretty: bool = typer.Option(True, "--pretty/--no-pretty", help=HELP_NO_PRETTY), 

41 debug: bool = typer.Option(False, "-d", "--debug", help=HELP_DEBUG), 

42) -> None: 

43 """Lists all installed CLI plugins. 

44 

45 This command acts as a wrapper around the shared `handle_list_plugins` 

46 utility to provide a consistent interface for developers. 

47 

48 Args: 

49 quiet (bool): If True, suppresses all output except for errors. 

50 verbose (bool): If True, includes Python/platform details in the output. 

51 fmt (str): The output format, "json" or "yaml". 

52 pretty (bool): If True, pretty-prints the output. 

53 debug (bool): If True, enables debug diagnostics. 

54 

55 Returns: 

56 None: 

57 

58 Raises: 

59 SystemExit: Always exits with a contract-compliant status code and 

60 payload, indicating success or detailing an error. 

61 """ 

62 command = "dev list-plugins" 

63 

64 validate_common_flags(fmt, command, quiet) 

65 

66 handle_list_plugins(command, quiet, verbose, fmt, pretty, debug)