Skip to content

Commit 7582a0f

Browse files
committed
🚀 feat(maniphest): Enhance task display and add new CLI options
- Refactor task display with unified `task_show()` method - Add `--show-history` and `--show-metadata` CLI options - Improve output formatting with YAML and transition history - Update version to 0.5.0rc0 - Deprecate legacy `--all` flag in favor of new options Fix linting
1 parent 42ff9b5 commit 7582a0f

File tree

3 files changed

+233
-140
lines changed

3 files changed

+233
-140
lines changed

‎phabfive/cli.py‎

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# python std lib
44
import re
55
import sys
6-
from datetime import datetime
7-
from pprint import pprint as pp
86

97
# 3rd party imports
108
from docopt import DocoptExit, Option, docopt, extras
@@ -121,14 +119,14 @@
121119

122120
sub_maniphest_show_args = """
123121
Usage:
124-
phabfive maniphest show <ticket_id> ([--all] | [--pp]) [options]
122+
phabfive maniphest show <ticket_id> [options]
125123
126124
Arguments:
127125
<ticket_id> Task ID (e.g., T123)
128126
129127
Options:
130-
--all Show all fields for a ticket
131-
--pp Show all fields rendering with pretty print
128+
--show-history Display transition history for columns, priority, and status
129+
--show-metadata Display metadata about the task
132130
-h, --help Show this help message and exit
133131
"""
134132

@@ -459,7 +457,7 @@ def run(cli_args, sub_args):
459457
if cli_args["<command>"] == "maniphest":
460458
maniphest_app = maniphest.Maniphest()
461459

462-
if sub_args["search"]:
460+
if sub_args.get("search"):
463461
# Parse filter patterns if provided
464462
transition_patterns = None
465463
if sub_args.get("--column"):
@@ -541,52 +539,18 @@ def run(cli_args, sub_args):
541539
print("Ticket URI: {0}".format(ticket["uri"]))
542540

543541
if sub_args.get("show"):
544-
_, result = maniphest_app.info(int(sub_args["<ticket_id>"][1:]))
545-
546-
if sub_args["--pp"]:
547-
pp({key: value for key, value in result.items()})
548-
elif sub_args["--all"]:
549-
print(f"Ticket ID: {result['id']}")
550-
print(f"phid: {result['phid']}")
551-
print(f"authorPHID: {result['authorPHID']}")
552-
print(f"ownerPHID: {result['ownerPHID']}")
553-
print(f"ccPHIDs: {result['ccPHIDs']}")
554-
print(f"status: {result['status']}")
555-
print(f"statusName: {result['statusName']}")
556-
print(f"isClosed: {result['isClosed']}")
557-
print(f"priority: {result['priority']}")
558-
print(f"priorityColor: {result['priorityColor']}")
559-
print(f"title: {result['title']}")
560-
print(f"description: {result['description']}")
561-
print(f"projectPHIDs: {result['projectPHIDs']}")
562-
print(f"uri: {result['uri']}")
563-
print(f"auxiliary: {result['auxiliary']}")
564-
print(f"objectName: {result['objectName']}")
565-
566-
date_created = datetime.fromtimestamp(int(result["dateCreated"]))
567-
print(f"dateCreated: {date_created}")
568-
569-
date_modified = datetime.fromtimestamp(int(result["dateModified"]))
570-
print(f"dateModified: {date_modified}")
571-
572-
print(f"dependsOnTaskPHIDs: {result['dependsOnTaskPHIDs']}")
573-
574-
# Display workboard transition history
575-
task_phid = result.get("phid")
576-
if task_phid:
577-
maniphest_app._display_task_transitions(task_phid)
578-
else:
579-
print(f"Ticket ID: {result['id']}")
580-
print(f"phid: {result['phid']}")
581-
print(f"status: {result['status']}")
582-
print(f"priority: {result['priority']}")
583-
print(f"title: {result['title']}")
584-
print(f"uri: {result['uri']}")
585-
date_created = datetime.fromtimestamp(int(result["dateCreated"]))
586-
print(f"dateCreated: {date_created}")
587-
588-
date_modified = datetime.fromtimestamp(int(result["dateModified"]))
589-
print(f"dateModified: {date_modified}")
542+
# Use new unified task_show() method
543+
task_id = int(sub_args["<ticket_id>"][1:])
544+
545+
# Handle flags
546+
show_history = sub_args.get("--show-history", False)
547+
show_metadata = sub_args.get("--show-metadata", False)
548+
549+
maniphest_app.task_show(
550+
task_id,
551+
show_history=show_history,
552+
show_metadata=show_metadata,
553+
)
590554
except PhabfiveException as e:
591555
# Catch all types of phabricator base exceptions
592556
print(f"CRITICAL :: {str(e)}", file=sys.stderr)

0 commit comments

Comments
 (0)