ODT table support

This commit is contained in:
Artem Kokos
2026-01-20 23:25:08 +07:00
parent 86041df76c
commit 2d66a4990b
4 changed files with 175 additions and 9 deletions

View File

@@ -32,6 +32,10 @@ def main(argv: Optional[List[str]] = None) -> int:
action="store_true",
help="Use compact plain-text output instead of table"
)
parser.add_argument(
"--output",
help="Path to output .odt file (e.g., report.odt). If omitted, prints to stdout."
)
args = parser.parse_args(argv)
try:
@@ -58,15 +62,31 @@ def main(argv: Optional[List[str]] = None) -> int:
print(f"✅ Total issues: {len(issue_hours)} [{args.date}]")
try:
if args.compact:
output = format_compact(issue_hours)
else:
output = format_table(issue_hours)
print(output)
except Exception as e:
print(f"❌ Formatting error: {e}", file=sys.stderr)
return 1
if args.output:
if not args.output.endswith(".odt"):
print("❌ Output file must end with .odt", file=sys.stderr)
return 1
try:
from .formatter_odt import format_odt
doc = format_odt(issue_hours)
doc.save(args.output)
print(f"✅ Report saved to {args.output}")
except ImportError:
print("❌ odfpy is not installed. Install with: pip install odfpy", file=sys.stderr)
return 1
except Exception as e:
print(f"❌ ODT export error: {e}", file=sys.stderr)
return 1
else:
try:
if args.compact:
output = format_compact(issue_hours)
else:
output = format_table(issue_hours)
print(output)
except Exception as e:
print(f"❌ Formatting error: {e}", file=sys.stderr)
return 1
return 0