From 18e1de7484e36d5a039d612dda9000a5c033b385 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Fri, 23 Jun 2023 19:14:43 +0300 Subject: [PATCH] Add update source option for source. --- CHANGELOG.org | 2 ++ pyproject.toml | 2 +- tui_rsync/cli/source/source_update.py | 28 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 71a0e22..182382a 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -51,4 +51,6 @@ Added *update label* option for groups. Added *Drone CI/CD* pipeline config. Added badge for pypi version of the package. +** 0.8.12 <2023-06-23 Fri> + Added *update source* option for source. diff --git a/pyproject.toml b/pyproject.toml index 525abc3..068119d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tui-rsync" -version = "0.8.11" +version = "0.8.12" description = "tui-rsync will help you to manage yours backups." authors = ["Kostiantyn Klochko "] readme = "README.rst" diff --git a/tui_rsync/cli/source/source_update.py b/tui_rsync/cli/source/source_update.py index ecacddb..1925a5b 100644 --- a/tui_rsync/cli/source/source_update.py +++ b/tui_rsync/cli/source/source_update.py @@ -57,6 +57,34 @@ def label( src = Source.get_source(label) src.update_label(new_label) +@source_update.command() +def source( + label: str = typer.Option( + None, "--label", "-l", + help="[b]The label[/] is a uniq identification of a [b]source[/].", + show_default=False + ), + new_source_path: str = typer.Option( + None, "--new-label", "-nl", + help="[b]The new source[/] will replace the [b]old source[/].", + show_default=False + ), +): + """ + [green b]Update[/] a source path of an [yellow]existing source[/]. + """ + if label is None: + console.print("What is the [yellow b]label of source[/]? ") + label = LabelPrompt.get_label_fzf() + + if new_source_path is None: + question = "What is the [yellow b]new source path of the source[/]? " + new_source_path = console.input(question) + + if Source.is_exist(label): + src = Source.get_source(label) + src.update_source_path(new_source_path) + @source_update.command() def args( label: str = typer.Option(