File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33from __future__ import annotations
44
55import typer
6- from rich .console import Console
76from loguru import logger
7+ from rich .console import Console
88
9+ from python_cli .commands .hello import hello
910from python_cli .config import get_settings
1011from python_cli .errors import AppError
1112from python_cli .logging import configure_logging
1213from python_cli .version import __version__
13- from python_cli .commands .hello import hello
1414
1515app = typer .Typer (no_args_is_help = True , help = "Generic Python CLI scaffold" )
1616console = Console ()
Original file line number Diff line number Diff line change 33from __future__ import annotations
44
55from pathlib import Path
6- from typing import Optional
76
8- from pydantic import Field , SecretStr
7+ from pydantic import Field
98from pydantic_settings import BaseSettings , SettingsConfigDict
109
1110
12- def _find_env_file () -> Optional [ Path ] :
11+ def _find_env_file () -> Path | None :
1312 cwd_env = Path .cwd () / ".env"
1413 if cwd_env .exists ():
1514 return cwd_env
@@ -26,7 +25,7 @@ class Settings(BaseSettings):
2625
2726 app_env : str = Field (default = "dev" , validation_alias = "APP_ENV" )
2827 log_level : str = Field (default = "INFO" , validation_alias = "LOG_LEVEL" )
29- data_dir : Optional [ Path ] = Field (default = None , validation_alias = "DATA_DIR" )
28+ data_dir : Path | None = Field (default = None , validation_alias = "DATA_DIR" )
3029
3130 model_config = SettingsConfigDict (
3231 env_file = str (_find_env_file ()) if _find_env_file () else None ,
Original file line number Diff line number Diff line change 44
55import sys
66from pathlib import Path
7+
78from loguru import logger
89
910
@@ -14,11 +15,16 @@ def configure_logging(level: str = "INFO") -> None:
1415 logs_dir = Path .home () / ".python-cli" / "logs"
1516 logs_dir .mkdir (parents = True , exist_ok = True )
1617
18+ console_format = (
19+ "<green>{time:HH:mm:ss}</green> | <level>{level: <8}</level> | "
20+ "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> | "
21+ "<level>{message}</level>"
22+ )
1723 logger .add (
1824 sys .stderr ,
1925 level = level ,
2026 colorize = True ,
21- format = "<green>{time:HH:mm:ss}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> | <level>{message}</level>" ,
27+ format = console_format ,
2228 )
2329
2430 logger .add (
You can’t perform that action at this time.
0 commit comments