@@ -7,6 +7,7 @@ from .config import Config
|
||||
from .client import fetch_issues_with_spent_time
|
||||
from .formatter import format_compact, format_table
|
||||
from .formatter_odt import format_odt
|
||||
from .formatter_csv import format_csv
|
||||
|
||||
|
||||
def parse_date_range(date_arg: str) -> tuple[str, str]:
|
||||
@@ -75,25 +76,35 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
print(f"✅ Total issues: {len(issue_hours)} [{args.date}]")
|
||||
|
||||
if args.output:
|
||||
if not args.output.endswith(".odt"):
|
||||
print("❌ Output file must end with .odt", file=sys.stderr)
|
||||
if not (args.output.endswith(".odt") or args.output.endswith(".csv")):
|
||||
print("❌ Output file must end with .odt or .csv", file=sys.stderr)
|
||||
return 1
|
||||
try:
|
||||
doc = format_odt(
|
||||
issue_hours,
|
||||
author=Config.get_author(args.author),
|
||||
from_date=from_date,
|
||||
to_date=to_date,
|
||||
fill_time=not args.no_time
|
||||
)
|
||||
|
||||
doc.save(args.output)
|
||||
try:
|
||||
if args.output.endswith(".odt"):
|
||||
doc = format_odt(
|
||||
issue_hours,
|
||||
author=Config.get_author(args.author),
|
||||
from_date=from_date,
|
||||
to_date=to_date,
|
||||
fill_time=not args.no_time
|
||||
)
|
||||
doc.save(args.output)
|
||||
elif args.output.endswith(".csv"):
|
||||
csv_content = format_csv(issue_hours, fill_time=not args.no_time)
|
||||
with open(args.output, "w", encoding="utf-8", newline="") as f:
|
||||
f.write(csv_content)
|
||||
|
||||
print(f"✅ Report saved to {args.output}")
|
||||
except ImportError:
|
||||
print("❌ odfpy is not installed. Install with: pip install odfpy", file=sys.stderr)
|
||||
except ImportError as e:
|
||||
if args.output.endswith(".odt"):
|
||||
print("❌ odfpy is not installed. Install with: pip install odfpy", file=sys.stderr)
|
||||
else:
|
||||
print(f"❌ Import error: {e}", file=sys.stderr)
|
||||
return 1
|
||||
except Exception as e:
|
||||
print(f"❌ ODT export error: {e}", file=sys.stderr)
|
||||
fmt = "ODT" if args.output.endswith(".odt") else "CSV"
|
||||
print(f"❌ {fmt} export error: {e}", file=sys.stderr)
|
||||
return 1
|
||||
else:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user