Skip to content

Commit

Permalink
when print_json, add color/no-color option
Browse files Browse the repository at this point in the history
  • Loading branch information
rcpirate authored Apr 28, 2024
1 parent f16d7dd commit 8ee20e0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tidevice3/cli/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
@click.option("-u", "--usb", is_flag=True, help="show only usb devices")
@click.option("-n", "--network", is_flag=True, help="show only network devices")
@click.option("--json", is_flag=True, help="output as json format")
@click.option("--color/--no-color", default=True, help="print colord")
@click.pass_context
def cli_list(ctx: click.Context, usb: bool, network: bool, json: bool):
def cli_list(ctx: click.Context, usb: bool, network: bool, json: bool, color: bool):
"""list connected devices"""
usbmux_address = ctx.obj["usbmux_address"]
devices = list_devices(usb, network, usbmux_address)
if json:
print_json([d.model_dump() for d in devices])
print_json([d.model_dump() for d in devices], color)
else:
headers = ["Identifier", "DeviceName", "ProductType", "ProductVersion", "ConnectionType"]
print_dict_as_table([d.model_dump() for d in devices], headers)
Expand Down

0 comments on commit 8ee20e0

Please sign in to comment.