Coverage for src/chuck_data/chuck_data/__main__.py: 0%

27 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-06-05 22:56 -0700

1#!/usr/bin/env python3 

2"""Entry point for chuck-data when run as a module.""" 

3 

4import sys 

5import os 

6import argparse 

7 

8# Add the src directory to Python path so we can import the TUI modules 

9src_path = os.path.join(os.path.dirname(__file__), "..") 

10if src_path not in sys.path: 

11 sys.path.insert(0, src_path) 

12 

13# Import version from this package 

14from .version import __version__ # noqa: E402 

15 

16# Import the TUI components 

17from logger import setup_logging # noqa: E402 

18from ui.tui import ChuckTUI # noqa: E402 

19 

20 

21def setup_arg_parser() -> argparse.ArgumentParser: 

22 """Create and return the CLI argument parser.""" 

23 parser = argparse.ArgumentParser(prog="chuck-data") 

24 parser.add_argument( 

25 "--version", 

26 action="version", 

27 version=f"%(prog)s {__version__}", 

28 help="Show program version and exit.", 

29 ) 

30 parser.add_argument("--no-color", action="store_true", help="Disable color output.") 

31 return parser 

32 

33 

34def main(argv: list[str] | None = None) -> None: 

35 """Main entry point for Chuck Data.""" 

36 setup_logging() 

37 

38 parser = setup_arg_parser() 

39 args = parser.parse_args(argv) 

40 

41 # Check for NO_COLOR environment variable (standard convention) 

42 no_color_env = os.environ.get("NO_COLOR", "").lower() in ("1", "true", "yes") 

43 no_color = args.no_color or no_color_env 

44 

45 # Initialize and run the TUI 

46 tui = ChuckTUI(no_color=no_color) 

47 try: 

48 tui.run() 

49 except EOFError: 

50 print("Thank you for using chuck!") 

51 

52 

53if __name__ == "__main__": 

54 main()