Add the function that gets a list of repositories from a namespace.

main
KKlochko 2 years ago
parent 1effa17117
commit 4dbb6018ce

@ -0,0 +1,8 @@
from rich.console import Console
import typer
from docker_tags_getter.cli.repos import repos
console = Console()
cli_app = typer.Typer(rich_markup_mode="rich")
cli_app.add_typer(repos, name="repos", help="Manage repos information")

@ -0,0 +1,55 @@
################################################################################
# Copyright (C) 2023 Kostiantyn Klochko <kklochko@protonmail.com> #
# #
# This file is part of docker_tags_getter. #
# #
# docker_tags_getter is free software: you can redistribute it and/or modify #
# it under the terms of the GNU Lesser General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or (at your #
# option) any later version. #
# #
# docker_tags_getter is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY #
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public #
# License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
#along with docker_tags_getter. If not, see <https://www.gnu.org/licenses/>. #
################################################################################
from rich.console import Console
from rich.prompt import Prompt
from typing import List, Optional
import typer
from docker_tags_getter.config.headers_config import HeadersConfig
from docker_tags_getter.fetcher.api_fetcher import ApiFetcher
from docker_tags_getter.api.v2.repositories_api import RepositoriesAPI
console = Console()
repos = typer.Typer()
@repos.command()
def all(
namespace: str = typer.Option(
None, "--namespace", "-ns",
help="[b]The namespace[/] is a uniq identification of [b]a user or a organisation[/].",
show_default=False
)
):
"""
[green b]All repos[/] will be returned for the [yellow b]namespace[/].
"""
if namespace is None:
console.print(f"[red b][ERROR] Please, give the namespace name!!![/]")
headers_config = HeadersConfig()
fetcher = ApiFetcher(headers_config)
repositories_api = RepositoriesAPI(fetcher, namespace)
names = repositories_api.get_list()
for name in names:
console.print(name)

@ -1,6 +1,7 @@
from docker_tags_getter.cli.cli import cli_app
def main():
pass
cli_app()
if __name__ == "__main__":
main()

Loading…
Cancel
Save