diff --git a/CHANGELOG.org b/CHANGELOG.org index aad689d..dfbcd24 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -2,4 +2,6 @@ ** 0.1.0 <2023-06-18 Sun> First release Added the function that gets a list of repositories from a namespace. +** 0.2.0 <2023-06-18 Sun> + Added the function that gets a list of tags from a repository. diff --git a/docker_tags_getter/cli/cli.py b/docker_tags_getter/cli/cli.py index 2c33f53..34268e5 100644 --- a/docker_tags_getter/cli/cli.py +++ b/docker_tags_getter/cli/cli.py @@ -1,8 +1,10 @@ from rich.console import Console import typer from docker_tags_getter.cli.repos import repos +from docker_tags_getter.cli.repo import repo console = Console() cli_app = typer.Typer(rich_markup_mode="rich") cli_app.add_typer(repos, name="repos", help="Manage repos information") +cli_app.add_typer(repo, name="repo", help="Manage repo information") diff --git a/docker_tags_getter/cli/repo.py b/docker_tags_getter/cli/repo.py new file mode 100644 index 0000000..e348301 --- /dev/null +++ b/docker_tags_getter/cli/repo.py @@ -0,0 +1,64 @@ +################################################################################ +# Copyright (C) 2023 Kostiantyn Klochko # +# # +# 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 . # +################################################################################ + +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 +from docker_tags_getter.api.v2.tags_api import TagsAPI + +console = Console() +repo = typer.Typer() + +@repo.command() +def tags( + 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 + ), + repository: str = typer.Option( + None, "--repository", "-r", + help="[b]The repository[/] is a uniq identification of [b]a project[/].", + show_default=False + ), +): + """ + [green b]All tags[/] will be returned for the [yellow b]namespace[/]. + """ + if namespace is None: + console.print(f"[red b][ERROR] Please, give the namespace name!!![/]") + + if namespace is None: + console.print(f"[red b][ERROR] Please, give the repository name!!![/]") + + headers_config = HeadersConfig() + fetcher = ApiFetcher(headers_config) + + tags_api = TagsAPI(fetcher, namespace, repository) + + tags = tags_api.get_list() + + for tag in tags: + console.print(tag) + diff --git a/pyproject.toml b/pyproject.toml index c610a5d..b26cb94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "docker-tags-getter" -version = "0.1.0" +version = "0.2.0" description = "" authors = ["Kostiantyn Klochko "] readme = "README.rst"