diff --git a/CHANGELOG.org b/CHANGELOG.org index 20a1627..0205af5 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -6,3 +6,7 @@ Added *sync one* function. Added Rsync wrappper. 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. diff --git a/tui_rsync/cli/label_prompt.py b/tui_rsync/cli/label_prompt.py index cf0514b..1f50469 100644 --- a/tui_rsync/cli/label_prompt.py +++ b/tui_rsync/cli/label_prompt.py @@ -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()) diff --git a/tui_rsync/cli/sync.py b/tui_rsync/cli/sync.py index 73e5c0c..b5d7f5b 100644 --- a/tui_rsync/cli/sync.py +++ b/tui_rsync/cli/sync.py @@ -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) diff --git a/tui_rsync/models/models.py b/tui_rsync/models/models.py index efe6646..ad28d6c 100644 --- a/tui_rsync/models/models.py +++ b/tui_rsync/models/models.py @@ -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))