Output formatting for fancy printing
This commit is contained in:
parent
0ab7f1fd62
commit
766cb74974
30
doxy/cli.py
30
doxy/cli.py
|
@ -52,7 +52,7 @@ def list(ctx):
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@services.only_if_service_exists
|
@services.only_if_service_exists
|
||||||
def edit(ctx, service):
|
def edit(ctx, service):
|
||||||
print(Rule(f"Editing {service}"))
|
output.print_header(f"Editing {service}")
|
||||||
compose_file = services.get_compose_file(
|
compose_file = services.get_compose_file(
|
||||||
Path(ctx.obj["CONFIG"].root_directory) / service
|
Path(ctx.obj["CONFIG"].root_directory) / service
|
||||||
)
|
)
|
||||||
|
@ -70,7 +70,7 @@ def edit(ctx, service):
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@services.only_if_service_exists
|
@services.only_if_service_exists
|
||||||
def control(ctx, service, command):
|
def control(ctx, service, command):
|
||||||
print(Rule(f"Controlling {service}"))
|
output.print_header(f"Controlling {service}")
|
||||||
compose_file = services.get_compose_file(
|
compose_file = services.get_compose_file(
|
||||||
Path(ctx.obj["CONFIG"].root_directory) / service
|
Path(ctx.obj["CONFIG"].root_directory) / service
|
||||||
)
|
)
|
||||||
|
@ -88,13 +88,13 @@ def update(ctx, service, remove):
|
||||||
compose_file = services.get_compose_file(
|
compose_file = services.get_compose_file(
|
||||||
Path(ctx.obj["CONFIG"].root_directory) / service
|
Path(ctx.obj["CONFIG"].root_directory) / service
|
||||||
)
|
)
|
||||||
print(Rule(f"Updating {service}"))
|
command_chain = {
|
||||||
command_chain = [
|
f"Stopping {service}": ["down" if remove else "stop"],
|
||||||
["down" if remove else "stop"],
|
f"Pulling {service} images": ["pull"],
|
||||||
["pull"],
|
f"Starting {service}": ["up", "-d"],
|
||||||
["up", "-d"],
|
}
|
||||||
]
|
for title, command in command_chain.items():
|
||||||
for command in command_chain:
|
output.print_header(ctx, title)
|
||||||
services.docker_compose_command(command, compose_file)
|
services.docker_compose_command(command, compose_file)
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,12 +106,12 @@ def status(ctx, service):
|
||||||
compose_file = services.get_compose_file(
|
compose_file = services.get_compose_file(
|
||||||
Path(ctx.obj["CONFIG"].root_directory) / service
|
Path(ctx.obj["CONFIG"].root_directory) / service
|
||||||
)
|
)
|
||||||
print(Rule(f"Status of {service}"))
|
command_chain = {
|
||||||
command_chain = [
|
"Containers": ["ps"],
|
||||||
["ps"],
|
"Running processes": ["top"],
|
||||||
["top"],
|
}
|
||||||
]
|
for title, command in command_chain.items():
|
||||||
for command in command_chain:
|
output.print_header(ctx, title)
|
||||||
services.docker_compose_command(command, compose_file)
|
services.docker_compose_command(command, compose_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from rich.tree import Tree
|
||||||
|
|
||||||
|
|
||||||
def _print_services_fancy(services: List[str]):
|
def _print_services_fancy(services: List[str]):
|
||||||
print(Rule(f"Listing services"))
|
print(Rule("Listing services"))
|
||||||
tree = Tree("[bold]Available Services")
|
tree = Tree("[bold]Available Services")
|
||||||
for service in services:
|
for service in services:
|
||||||
tree.add(service)
|
tree.add(service)
|
||||||
|
@ -27,3 +27,15 @@ def print_services(ctx: Context, services: List[str]):
|
||||||
_print_services_simple(services)
|
_print_services_simple(services)
|
||||||
case _:
|
case _:
|
||||||
echo("Unknown format choice")
|
echo("Unknown format choice")
|
||||||
|
|
||||||
|
|
||||||
|
def _print_header_fancy(text: str):
|
||||||
|
print(Rule(text))
|
||||||
|
|
||||||
|
|
||||||
|
def print_header(ctx: Context, text: str):
|
||||||
|
match ctx.obj["FORMAT"]:
|
||||||
|
case "fancy":
|
||||||
|
_print_header_fancy(text)
|
||||||
|
case _:
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue