ODT table support
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user