Coverage for src / ezplog / cli / commands / _version.py: 28.12%

28 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-30 19:43 +0000

1# /////////////////////////////////////////////////////////////// 

2# EZPL - CLI Version Command 

3# Project: ezpl 

4# /////////////////////////////////////////////////////////////// 

5 

6""" 

7CLI command for displaying version information. 

8 

9This module provides the version command for Ezpl. 

10""" 

11 

12from __future__ import annotations 

13 

14# /////////////////////////////////////////////////////////////// 

15# IMPORTS 

16# /////////////////////////////////////////////////////////////// 

17# Standard library imports 

18import click 

19 

20# Third-party imports 

21from rich.panel import Panel 

22from rich.text import Text 

23 

24# Local imports 

25import ezplog as ezpl 

26 

27from .._console import console 

28 

29# /////////////////////////////////////////////////////////////// 

30# COMMANDS 

31# /////////////////////////////////////////////////////////////// 

32 

33 

34@click.command(name="version", help="Display version information") 

35@click.option( 

36 "--full", 

37 "-f", 

38 is_flag=True, 

39 help="Display full version information", 

40) 

41def version_command(full: bool) -> None: 

42 """ 

43 Display version information. 

44 

45 Show the current version of Ezpl. 

46 Use --full for detailed version information. 

47 """ 

48 version = getattr(ezpl, "__version__", "unknown") 

49 author = getattr(ezpl, "__author__", "unknown") 

50 license_type = getattr(ezpl, "__license__", "unknown") 

51 

52 if full: 

53 # Full version info 

54 text = Text() 

55 text.append("Ezpl ", style="bold bright_blue") 

56 text.append(f"v{version}", style="bold green") 

57 text.append("\n\n", style="reset") 

58 

59 text.append("Author: ", style="dim") 

60 text.append(f"{author}\n", style="white") 

61 text.append("License: ", style="dim") 

62 text.append(f"{license_type}\n", style="white") 

63 

64 url = getattr(ezpl, "__url__", None) 

65 if url: 

66 text.append("URL: ", style="dim") 

67 text.append(f"{url}\n", style="white") 

68 

69 panel = Panel( 

70 text, 

71 title="[bold bright_blue]Version Information[/bold bright_blue]", 

72 border_style="bright_blue", 

73 padding=(1, 2), 

74 ) 

75 console.print(panel) 

76 else: 

77 # Simple version 

78 console.print( 

79 f"[bold bright_blue]Ezpl[/bold bright_blue] v[bold green]{version}[/bold green]" 

80 )