From 88d7a46f66861ec7cbab24bd4dde20176007873c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Sun, 19 Mar 2023 14:33:17 +0200 Subject: [PATCH] (Added) remove option for source. Moved source logic to .cli.source. --- CHANGELOG.org | 3 ++ tui_rsync/cli/__init__.py | 1 - tui_rsync/cli/cli.py | 2 +- tui_rsync/cli/source/__init__.py | 1 + tui_rsync/cli/{ => source}/source.py | 4 +- tui_rsync/cli/source/source_remove.py | 48 +++++++++++++++++++++ tui_rsync/cli/{ => source}/source_update.py | 0 7 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 tui_rsync/cli/source/__init__.py rename tui_rsync/cli/{ => source}/source.py (94%) create mode 100644 tui_rsync/cli/source/source_remove.py rename tui_rsync/cli/{ => source}/source_update.py (100%) diff --git a/CHANGELOG.org b/CHANGELOG.org index 405c7dd..3af4d72 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -29,4 +29,7 @@ ** 0.8.1 <2023-03-18 Sat> Made the package executable. Updated the package information. +** 0.8.2 <2023-03-19 Sun> + Added remove option for source. + Moved source logic to .cli.source. diff --git a/tui_rsync/cli/__init__.py b/tui_rsync/cli/__init__.py index ffaa1b3..97ed1be 100644 --- a/tui_rsync/cli/__init__.py +++ b/tui_rsync/cli/__init__.py @@ -1,5 +1,4 @@ from tui_rsync.cli.cli import cli_app -from tui_rsync.cli.source import source from tui_rsync.cli.sync import sync from tui_rsync.cli.rsync import Rsync from tui_rsync.cli.label_prompt import LabelPrompt diff --git a/tui_rsync/cli/cli.py b/tui_rsync/cli/cli.py index b036777..13d61a6 100644 --- a/tui_rsync/cli/cli.py +++ b/tui_rsync/cli/cli.py @@ -19,7 +19,7 @@ from rich.console import Console import typer -from tui_rsync.cli.source import source +from tui_rsync.cli.source.source import source from tui_rsync.cli.sync import sync from tui_rsync.cli.groups import groups diff --git a/tui_rsync/cli/source/__init__.py b/tui_rsync/cli/source/__init__.py new file mode 100644 index 0000000..d9c71b9 --- /dev/null +++ b/tui_rsync/cli/source/__init__.py @@ -0,0 +1 @@ +from tui_rsync.cli.source import source diff --git a/tui_rsync/cli/source.py b/tui_rsync/cli/source/source.py similarity index 94% rename from tui_rsync/cli/source.py rename to tui_rsync/cli/source/source.py index ad3bb60..e5400c4 100644 --- a/tui_rsync/cli/source.py +++ b/tui_rsync/cli/source/source.py @@ -24,11 +24,13 @@ import typer from tui_rsync.models.models import Source, Destination, SyncCommand, Path from tui_rsync.cli.label_prompt import LabelPrompt -from tui_rsync.cli.source_update import source_update +from tui_rsync.cli.source.source_update import source_update +from tui_rsync.cli.source.source_remove import source_remove console = Console() source = typer.Typer() source.add_typer(source_update, name="update", help="Update sources") +source.add_typer(source_remove, name="remove", help="Remove sources") @source.command() def add( diff --git a/tui_rsync/cli/source/source_remove.py b/tui_rsync/cli/source/source_remove.py new file mode 100644 index 0000000..d9fea32 --- /dev/null +++ b/tui_rsync/cli/source/source_remove.py @@ -0,0 +1,48 @@ +################################################################################ +# 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 Source, Destination, SyncCommand, Path +from tui_rsync.cli.label_prompt import LabelPrompt + +console = Console() +source_remove = typer.Typer() + +@source_remove.command() +def one( + label: str = typer.Option( + None, "--label", "-l", + help="[b]The label[/] is a uniq identification of a [b]source[/].", + show_default=False + ) +): + """ + [red b]Remove[/] an [yellow]existing source[/]. + """ + if label is None: + label = LabelPrompt.get_label_fzf() + + if Source.is_exist(label): + src = Source.get_source(label) + src.delete_instance() + diff --git a/tui_rsync/cli/source_update.py b/tui_rsync/cli/source/source_update.py similarity index 100% rename from tui_rsync/cli/source_update.py rename to tui_rsync/cli/source/source_update.py