Error handling if service does not exist
This commit is contained in:
parent
504aec1302
commit
5149c97150
23
doxy/cli.py
23
doxy/cli.py
|
@ -1,3 +1,4 @@
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
@ -40,10 +41,13 @@ def complete_service_name(ctx, param, incomplete):
|
||||||
@click.argument("service", nargs=1, shell_complete=complete_service_name)
|
@click.argument("service", nargs=1, shell_complete=complete_service_name)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def edit(ctx, service):
|
def edit(ctx, service):
|
||||||
compose_file = services.get_compose_file(
|
try:
|
||||||
Path(ctx.obj["CONFIG"].root_directory) / service
|
compose_file = services.get_compose_file(
|
||||||
)
|
Path(ctx.obj["CONFIG"].root_directory) / service
|
||||||
click.edit(filename=Path(compose_file))
|
)
|
||||||
|
click.edit(filename=Path(compose_file))
|
||||||
|
except FileNotFoundError:
|
||||||
|
click.echo(f"Service `{service}' not found", sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
@ -51,10 +55,13 @@ def edit(ctx, service):
|
||||||
@click.argument("service", nargs=1, shell_complete=complete_service_name)
|
@click.argument("service", nargs=1, shell_complete=complete_service_name)
|
||||||
@click.argument("command", nargs=-1)
|
@click.argument("command", nargs=-1)
|
||||||
def control(ctx, service, command):
|
def control(ctx, service, command):
|
||||||
compose_file = services.get_compose_file(
|
try:
|
||||||
Path(ctx.obj["CONFIG"].root_directory) / service
|
compose_file = services.get_compose_file(
|
||||||
)
|
Path(ctx.obj["CONFIG"].root_directory) / service
|
||||||
services.docker_compose_command(command, compose_file)
|
)
|
||||||
|
services.docker_compose_command(command, compose_file)
|
||||||
|
except FileNotFoundError:
|
||||||
|
click.echo(f"Service `{service}' not found", sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
main.add_command(list)
|
main.add_command(list)
|
||||||
|
|
Loading…
Reference in New Issue