mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-20 05:37:43 +00:00
(Added) update label option for source.
This commit is contained in:
@@ -39,4 +39,6 @@
|
|||||||
Added *remove all* option for sources.
|
Added *remove all* option for sources.
|
||||||
** 0.8.6 <2023-03-23 Thu>
|
** 0.8.6 <2023-03-23 Thu>
|
||||||
Added *remove all* option for groups.
|
Added *remove all* option for groups.
|
||||||
|
** 0.8.6 <2023-03-23 Thu>
|
||||||
|
Added *update label* option for source.
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,35 @@ from tui_rsync.cli.label_prompt import LabelPrompt
|
|||||||
console = Console()
|
console = Console()
|
||||||
source_update = typer.Typer()
|
source_update = typer.Typer()
|
||||||
|
|
||||||
|
@source_update.command()
|
||||||
|
def label(
|
||||||
|
label: str = typer.Option(
|
||||||
|
None, "--label", "-l",
|
||||||
|
help="[b]The label[/] is a uniq identification of a [b]source[/].",
|
||||||
|
show_default=False
|
||||||
|
),
|
||||||
|
new_label: str = typer.Option(
|
||||||
|
None, "--new-label", "-nl",
|
||||||
|
help="[b]The new label[/] will replace the [b]old source label[/].",
|
||||||
|
show_default=False
|
||||||
|
),
|
||||||
|
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
[green b]Update[/] an [yellow]existing source label[/].
|
||||||
|
"""
|
||||||
|
if label is None:
|
||||||
|
console.print("What is the [yellow b]old label of source[/]? ")
|
||||||
|
label = LabelPrompt.get_label_fzf()
|
||||||
|
|
||||||
|
if new_label is None:
|
||||||
|
question = "What is the [yellow b]new label of source[/]? "
|
||||||
|
new_label = LabelPrompt.ask_uuid(question)
|
||||||
|
|
||||||
|
if Source.is_exist(label):
|
||||||
|
src = Source.get_source(label)
|
||||||
|
src.update_label(new_label)
|
||||||
|
|
||||||
@source_update.command()
|
@source_update.command()
|
||||||
def args(
|
def args(
|
||||||
label: str = typer.Option(
|
label: str = typer.Option(
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ class Source(BaseModel):
|
|||||||
src.save()
|
src.save()
|
||||||
return src
|
return src
|
||||||
|
|
||||||
|
def update_label(self, new_label):
|
||||||
|
self.label = new_label
|
||||||
|
self.save()
|
||||||
|
|
||||||
def update_args(self, args):
|
def update_args(self, args):
|
||||||
args_obj = SyncCommand.get_sync_command(args)
|
args_obj = SyncCommand.get_sync_command(args)
|
||||||
self.args = args_obj
|
self.args = args_obj
|
||||||
|
|||||||
Reference in New Issue
Block a user