(Added) sync all function.

Added all_labels_except for choosing many labels.
Added fzf function for using all_labels_except.
This commit is contained in:
2023-03-01 20:53:39 +02:00
parent 467989bbd5
commit b99f2a0ffa
4 changed files with 23 additions and 1 deletions
+7 -1
View File
@@ -21,7 +21,7 @@ from rich.console import Console
from rich.prompt import Prompt
from pyfzf import FzfPrompt
import uuid
from models.models import all_labels
from models.models import all_labels, all_labels_except
console = Console()
@@ -37,6 +37,12 @@ class LabelPrompt:
label = Prompt.ask(question, default=uid)
return label
@staticmethod
def get_label_fzf() -> str:
fzf = FzfPrompt()
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())
+8
View File
@@ -23,6 +23,7 @@ from typing import List, Optional
import typer
from models.models import Source, Destination, SyncCommand, Path
from models.models import all_labels
from cli.label_prompt import LabelPrompt
from cli.rsync import Rsync
@@ -47,3 +48,10 @@ def one(
for dest in src.destinations:
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)
+4
View File
@@ -80,3 +80,7 @@ def create_tables():
def all_labels():
with db:
return Source.select(Source.label)
def all_labels_except(labels):
with db:
return Source.select(Source.label).where(Source.label.not_in(labels))