Optional disable fill time for console output too
This commit is contained in:
@@ -46,7 +46,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
parser.add_argument(
|
||||
"--no-time",
|
||||
action="store_true",
|
||||
help="Do not include 'Затрачено за отчетный период' column in ODT report"
|
||||
help="Do not include spent time into table"
|
||||
)
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
@@ -98,9 +98,9 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
else:
|
||||
try:
|
||||
if args.compact:
|
||||
output = format_compact(issue_hours)
|
||||
output = format_compact(issue_hours, fill_time=not args.no_time)
|
||||
else:
|
||||
output = format_table(issue_hours)
|
||||
output = format_table(issue_hours, fill_time=not args.no_time)
|
||||
print(output)
|
||||
except Exception as e:
|
||||
print(f"❌ Formatting error: {e}", file=sys.stderr)
|
||||
|
||||
@@ -33,7 +33,7 @@ def hours_to_human(hours: float) -> str:
|
||||
return " ".join(parts) if parts else "0ч"
|
||||
|
||||
|
||||
def format_compact(issue_hours: List[Tuple[Issue, float]]) -> str:
|
||||
def format_compact(issue_hours: List[Tuple[Issue, float]], fill_time: bool = True) -> str:
|
||||
lines = []
|
||||
prev_project = None
|
||||
prev_version = None
|
||||
@@ -42,10 +42,11 @@ def format_compact(issue_hours: List[Tuple[Issue, float]]) -> str:
|
||||
project = str(issue.project)
|
||||
version = get_version(issue)
|
||||
status = str(issue.status)
|
||||
time_text = hours_to_human(hours) if fill_time else ""
|
||||
|
||||
display_project = project if project != prev_project else ""
|
||||
display_version = version if (project != prev_project or version != prev_version) else ""
|
||||
lines.append(f"{display_project} | {display_version} | {issue.id}. {issue.subject} | {status} | {hours_to_human(hours)}")
|
||||
lines.append(f"{display_project} | {display_version} | {issue.id}. {issue.subject} | {status} | {time_text}")
|
||||
|
||||
prev_project = project
|
||||
prev_version = version
|
||||
@@ -53,7 +54,7 @@ def format_compact(issue_hours: List[Tuple[Issue, float]]) -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def format_table(issue_hours: List[Tuple[Issue, float]]) -> str:
|
||||
def format_table(issue_hours: List[Tuple[Issue, float]], fill_time: bool = True) -> str:
|
||||
from tabulate import tabulate
|
||||
|
||||
rows = [['Проект', 'Версия', 'Задача', 'Статус', 'Затрачено']]
|
||||
@@ -65,6 +66,7 @@ def format_table(issue_hours: List[Tuple[Issue, float]]) -> str:
|
||||
version = get_version(issue)
|
||||
status_en = str(issue.status)
|
||||
status_ru = STATUS_TRANSLATION.get(status_en, status_en)
|
||||
time_text = hours_to_human(hours) if fill_time else ""
|
||||
|
||||
display_project = project if project != prev_project else ""
|
||||
display_version = version if (project != prev_project or version != prev_version) else ""
|
||||
@@ -74,7 +76,7 @@ def format_table(issue_hours: List[Tuple[Issue, float]]) -> str:
|
||||
display_version,
|
||||
f"{issue.id}. {issue.subject}",
|
||||
status_ru,
|
||||
hours_to_human(hours)
|
||||
time_text
|
||||
])
|
||||
|
||||
prev_project = project
|
||||
|
||||
Reference in New Issue
Block a user