From 8fe226b282be8840e6816fe75516dfce8f32cccf Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sun, 25 Jun 2023 18:05:36 +0300 Subject: [PATCH] Add the show one option for Group. --- CHANGELOG.org | 2 ++ pyproject.toml | 2 +- tui_rsync/cli/groups/group_show.py | 53 ++++++++++++++++++++++++++++++ tui_rsync/cli/groups/groups.py | 2 ++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tui_rsync/cli/groups/group_show.py diff --git a/CHANGELOG.org b/CHANGELOG.org index 506d813..8d386f6 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -55,4 +55,6 @@ Added *update source* option for source. ** 0.8.13 <2023-06-24 Sat> Added *show one* option for Source. +** 0.8.14 <2023-06-25 Sun> + Added *show one* option for Group. diff --git a/pyproject.toml b/pyproject.toml index d7cb0f9..63f382c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tui-rsync" -version = "0.8.13" +version = "0.8.14" description = "tui-rsync will help you to manage yours backups." authors = ["Kostiantyn Klochko "] readme = "README.rst" diff --git a/tui_rsync/cli/groups/group_show.py b/tui_rsync/cli/groups/group_show.py new file mode 100644 index 0000000..385d574 --- /dev/null +++ b/tui_rsync/cli/groups/group_show.py @@ -0,0 +1,53 @@ +################################################################################ +# Copyright (C) 2023 Kostiantyn Klochko # +# # +# This file is part of tui-rsync. # +# # +# tui-rsync is free software: you can redistribute it and/or modify it under # +# uthe terms of the GNU General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# tui-rsync 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 General Public License for more # +# details. # +# # +# You should have received a copy of the GNU General Public License along with # +# tui-rsync. If not, see . # +################################################################################ + +from rich.console import Console +from rich.prompt import Prompt +from typing import List, Optional +import typer + +from tui_rsync.models.models import Group, GroupSource +from tui_rsync.cli.groups.group_prompt import GroupPrompt + +console = Console() +group_show = typer.Typer() + +@group_show.command() +def one( + group_label: str = typer.Option( + None, "--group-label", "-l", + help="[b]The label[/] is a uniq identification of a [b]group[/].", + show_default=False + ), +): + """ + [green b]Show[/] an [yellow]existing group[/]. + """ + if group_label is None: + console.print("What is the [yellow b]label of the group[/]? ") + group_label = GroupPrompt.get_label_fzf() + + if not Group.is_exist(group_label): + console.print("[red b][ERROR][/] Source does not exists!!!") + return + + group = Group.get_group(group_label) + + console.print(group.show_format()) + diff --git a/tui_rsync/cli/groups/groups.py b/tui_rsync/cli/groups/groups.py index 766d327..f8dfb00 100644 --- a/tui_rsync/cli/groups/groups.py +++ b/tui_rsync/cli/groups/groups.py @@ -25,11 +25,13 @@ import typer from tui_rsync.cli.label_prompt import LabelPrompt from tui_rsync.cli.rsync import Rsync from tui_rsync.models.models import Group, count_all_labels_except +from tui_rsync.cli.groups.group_show import group_show from tui_rsync.cli.groups.group_update import group_update from tui_rsync.cli.groups.group_remove import group_remove console = Console() groups = typer.Typer() +groups.add_typer(group_show, name="show", help="Show groups") groups.add_typer(group_update, name="update", help="Update groups") groups.add_typer(group_remove, name="remove", help="Remove groups")