def view_tools()

in pipe-cli/pipe.py [0:0]


def view_tools(tool_path,
               registry,
               group,
               tool,
               version):
    """
    Either shows details of a tool / tool version or lists tools / tool groups.

    Notice that docker registry should be specified explicitly if there is more than one
    allowed docker registry registered in cloud pipeline.

    \b
    List tools in a personal, library or default tool group:
      pipe view-tools

    \b
    List tool groups in a single docker registry:
      pipe view-tools --registry docker-registry:port
      pipe view-tools docker-registry:port

    \b
    List tools in a single tool group:
      pipe view-tools --group library
      pipe view-tools --registry docker-registry:port --group library
      pipe view-tools docker-registry:port/library

    \b
    Show details of a single tool:
      pipe view-tools --tool docker-registry:port/library/ubuntu
      pipe view-tools --group library --tool ubuntu
      pipe view-tools --registry docker-registry:port --group library --tool ubuntu
      pipe view-tools docker-registry:port/library/ubuntu

    \b
    Show details of a single tool version:
      pipe view-tools --tool docker-registry:port/library/ubuntu:18.04
      pipe view-tools --group library --tool ubuntu --version 18.04
      pipe view-tools --registry docker-registry:port --group library --tool ubuntu --version 18.04
      pipe view-tools docker-registry:port/library/ubuntu:18.04
    """
    if tool_path and (registry or group or tool or version):
        click.echo('Tool path positional argument cannot be specified along with the named parameters.', err=True)
        sys.exit(1)
    if tool_path:
        registry, group, tool, version = split_tool_path(tool_path, registry, group, tool, version)
    elif tool and not registry and not group and not version:
        registry, group, tool, version = split_tool_path(tool, registry, group, None, version, strict=True)
    else:
        if version and not tool:
            click.echo('Please specify tool name.', err=True)
            sys.exit(1)
        if tool and not group:
            click.echo('Please specify tool group.', err=True)
            sys.exit(1)

    if not registry and not group and not tool and not version:
        ToolOperations.view_default_group()
    elif group and tool and version:
        ToolOperations.view_version(group, tool, version, registry)
    elif group and tool:
        ToolOperations.view_tool(group, tool, registry)
    elif group:
        ToolOperations.view_group(group, registry)
    elif registry:
        ToolOperations.view_registry(registry)
    else:
        click.echo('Specify either registry, group, tool or version parameters', err=True)
        sys.exit(1)