(Added) update label option for source.

dev
KKlochko 2 years ago
parent cf88cdbc9f
commit cb5b4fae29

@ -39,4 +39,6 @@
Added *remove all* option for sources.
** 0.8.6 <2023-03-23 Thu>
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()
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()
def args(
label: str = typer.Option(

@ -82,6 +82,10 @@ class Source(BaseModel):
src.save()
return src
def update_label(self, new_label):
self.label = new_label
self.save()
def update_args(self, args):
args_obj = SyncCommand.get_sync_command(args)
self.args = args_obj

Loading…
Cancel
Save