feat(console): scaffold project structure and config
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
0
console/__init__.py
Normal file
0
console/__init__.py
Normal file
7
console/__main__.py
Normal file
7
console/__main__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""
|
||||
Allow running the package with: python -m console
|
||||
"""
|
||||
|
||||
from console.main import main
|
||||
|
||||
main()
|
||||
39
console/config.py
Normal file
39
console/config.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
Configuration settings for the AUTOPARTES console application.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Application metadata
|
||||
VERSION = "1.0.0"
|
||||
APP_NAME = "AUTOPARTES"
|
||||
APP_SUBTITLE = "Sistema de Catalogo de Autopartes"
|
||||
|
||||
# Database path (relative to the console/ directory, resolved to absolute)
|
||||
_CONSOLE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
DB_PATH = os.path.join(_CONSOLE_DIR, "..", "vehicle_database", "vehicle_database.db")
|
||||
DB_PATH = os.path.normpath(DB_PATH)
|
||||
|
||||
# NHTSA VIN Decoder API
|
||||
NHTSA_API_URL = "https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVin"
|
||||
VIN_CACHE_DAYS = 30
|
||||
|
||||
# Display defaults
|
||||
DEFAULT_MODE = "vt220"
|
||||
PAGE_SIZE = 15
|
||||
|
||||
# VT220 color pairs: (foreground, background)
|
||||
# These map to curses color pair indices used by the renderer.
|
||||
COLORS_VT220 = {
|
||||
"header": ("green", "black"),
|
||||
"footer": ("black", "green"),
|
||||
"normal": ("green", "black"),
|
||||
"highlight": ("black", "green"),
|
||||
"border": ("green", "black"),
|
||||
"title": ("white", "black"),
|
||||
"error": ("red", "black"),
|
||||
"info": ("cyan", "black"),
|
||||
"field_label": ("green", "black"),
|
||||
"field_value": ("white", "black"),
|
||||
"field_active": ("black", "cyan"),
|
||||
}
|
||||
0
console/core/__init__.py
Normal file
0
console/core/__init__.py
Normal file
65
console/main.py
Normal file
65
console/main.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""
|
||||
Entry point for the AUTOPARTES Pick/VT220-style console application.
|
||||
|
||||
Usage:
|
||||
python -m console # via package
|
||||
python -m console.main # via module
|
||||
python console/main.py # direct
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from console.config import VERSION, APP_NAME, APP_SUBTITLE, DB_PATH, DEFAULT_MODE
|
||||
|
||||
|
||||
def parse_args(argv=None):
|
||||
"""Parse command-line arguments."""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=APP_NAME.lower(),
|
||||
description=f"{APP_NAME} - {APP_SUBTITLE}",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--mode",
|
||||
choices=["vt220", "modern"],
|
||||
default=DEFAULT_MODE,
|
||||
help=f"Display mode (default: {DEFAULT_MODE})",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
action="version",
|
||||
version=f"{APP_NAME} {VERSION}",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--db",
|
||||
default=DB_PATH,
|
||||
help="Path to the vehicle database (default: auto-detected)",
|
||||
)
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
"""Main entry point: parse args, set up renderer, DB, and launch the app."""
|
||||
args = parse_args(argv)
|
||||
|
||||
db_path = args.db
|
||||
mode = args.mode
|
||||
|
||||
# Lazy imports so the module can be loaded without curses available
|
||||
# (e.g. during tests or when just checking --version).
|
||||
from console.core.database import Database
|
||||
from console.renderers import create_renderer
|
||||
from console.core.app import App
|
||||
|
||||
db = Database(db_path)
|
||||
renderer = create_renderer(mode)
|
||||
app = App(renderer=renderer, db=db)
|
||||
|
||||
try:
|
||||
app.run()
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
0
console/renderers/__init__.py
Normal file
0
console/renderers/__init__.py
Normal file
0
console/screens/__init__.py
Normal file
0
console/screens/__init__.py
Normal file
0
console/tests/__init__.py
Normal file
0
console/tests/__init__.py
Normal file
0
console/utils/__init__.py
Normal file
0
console/utils/__init__.py
Normal file
Reference in New Issue
Block a user