(Added) sync all function.

Added all_labels_except for choosing many labels.
Added fzf function for using all_labels_except.
dev
KKlochko 2 years ago
parent 467989bbd5
commit b99f2a0ffa

@ -6,3 +6,7 @@
Added *sync one* function. Added *sync one* function.
Added Rsync wrappper. Added Rsync wrappper.
Added fzf_prompt, all_labels for choosing a label of source. Added fzf_prompt, all_labels for choosing a label of source.
** 0.3.5 <2023-03-01>
Added *sync all* function.
Added all_labels_except for choosing many labels.
Added fzf function for using all_labels_except.

@ -21,7 +21,7 @@ from rich.console import Console
from rich.prompt import Prompt from rich.prompt import Prompt
from pyfzf import FzfPrompt from pyfzf import FzfPrompt
import uuid import uuid
from models.models import all_labels from models.models import all_labels, all_labels_except
console = Console() console = Console()
@ -37,6 +37,12 @@ class LabelPrompt:
label = Prompt.ask(question, default=uid) label = Prompt.ask(question, default=uid)
return label return label
@staticmethod
def get_label_fzf() -> str: def get_label_fzf() -> str:
fzf = FzfPrompt() fzf = FzfPrompt()
return fzf.prompt(all_labels().iterator()) return fzf.prompt(all_labels().iterator())
@staticmethod
def get_label_except_fzf(labels = None) -> str:
fzf = FzfPrompt()
return fzf.prompt(all_labels_except(labels).iterator())

@ -23,6 +23,7 @@ from typing import List, Optional
import typer import typer
from models.models import Source, Destination, SyncCommand, Path from models.models import Source, Destination, SyncCommand, Path
from models.models import all_labels
from cli.label_prompt import LabelPrompt from cli.label_prompt import LabelPrompt
from cli.rsync import Rsync from cli.rsync import Rsync
@ -47,3 +48,10 @@ def one(
for dest in src.destinations: for dest in src.destinations:
rsync.run_one(str(src.source), str(dest)) rsync.run_one(str(src.source), str(dest))
@sync.command()
def all():
"""
[green b]Sync[/] [yellow]all sources[/] with theirs backups.
"""
for label in all_labels().iterator():
one(label.label)

@ -80,3 +80,7 @@ def create_tables():
def all_labels(): def all_labels():
with db: with db:
return Source.select(Source.label) return Source.select(Source.label)
def all_labels_except(labels):
with db:
return Source.select(Source.label).where(Source.label.not_in(labels))

Loading…
Cancel
Save