mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-12 17:57:43 +00:00
(Added) update label option for source.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user