Exemple #1
0
def list_ports(composition: mzcompose.Composition,
               service: Optional[str]) -> int:
    if service is None:
        raise errors.MzRuntimeError(
            f"list-ports command requires a service argument")
    for port in composition.find_host_ports(service):
        print(port)
    return 0
Exemple #2
0
def web(composition: mzcompose.Composition, service: Optional[str]) -> int:
    if service is None:
        raise errors.MzRuntimeError(f"web command requires a service argument")
    ports = composition.find_host_ports(service)
    if len(ports) == 1:
        webbrowser.open(f"http://localhost:{ports[0]}")
    elif not ports:
        raise errors.MzRuntimeError(f"No running services matched {service!r}")
    else:
        raise errors.MzRuntimeError(
            f"Too many ports matched {service!r}, found: {ports}")
    return 0