Loading conftest.py +5 −4 Original line number Diff line number Diff line import shutil from functools import partial from pathlib import Path Loading @@ -22,18 +23,18 @@ def configure_rclone(monkeypatch): @pytest.fixture(scope='session') def plus_sync(): def plus_sync_cmd(): return partial(runner.invoke, ps_command.app) @pytest.fixture(scope='function') def initialized(plus_sync): def initialized(plus_sync_cmd): # remove config file if it exists Path('plus_sync.toml').unlink(missing_ok=True) # remove data folder recursively if it exists if Path('data_synced').exists(): Path('data_synced').rmdir() result = plus_sync(['init'], input='test\n') shutil.rmtree('data_synced') result = plus_sync_cmd(['init'], input='test\n') assert result.exit_code == 0 assert 'Done' in result.stdout Loading plus_sync/cmd/commands/list_subjects.py +9 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,20 @@ import typer from ...config import Config from ..app import app from ..helpers.typer import get_hashed_default @app.command() def list_subjects( remote_name: Annotated[str, typer.Argument(help='The name of the remote')], hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True, hash_subject_ids: Annotated[ bool, typer.Option( help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.', default_factory=get_hashed_default, show_default=False, ), ], ): """ List the subjects in a sync endpoint. Loading plus_sync/cmd/commands/ls.py +9 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,20 @@ import typer from ...config import Config from ..app import app from ..helpers.typer import get_hashed_default @app.command(no_args_is_help=True) def ls( remote_name: Annotated[str, typer.Argument(help='The name of the remote to use.')], hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True, hash_subject_ids: Annotated[ bool, typer.Option( help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.', default_factory=get_hashed_default, show_default=False, ), ], ): """ List the files that are available. Loading plus_sync/cmd/commands/sync.py +9 −1 Original line number Diff line number Diff line Loading @@ -6,12 +6,20 @@ from tqdm import tqdm from ...config import Config from ..app import app from ..helpers.typer import get_hashed_default @app.command(no_args_is_help=True) def sync( remote_name: Annotated[str, typer.Argument(help='The name of the remote to use.')], hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True, hash_subject_ids: Annotated[ bool, typer.Option( help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.', default_factory=get_hashed_default, show_default=False, ), ], dry_run: Annotated[bool, typer.Option(help='Whether to do a dry run.')] = False, limit: Annotated[int, typer.Option(help='Limit the number of subjects to sync.')] = None, ): Loading plus_sync/cmd/helpers/typer.py 0 → 100644 +6 −0 Original line number Diff line number Diff line from plus_sync.config import Config def get_hashed_default() -> bool: config = Config.from_cmdargs() return config.hash_subject_ids Loading
conftest.py +5 −4 Original line number Diff line number Diff line import shutil from functools import partial from pathlib import Path Loading @@ -22,18 +23,18 @@ def configure_rclone(monkeypatch): @pytest.fixture(scope='session') def plus_sync(): def plus_sync_cmd(): return partial(runner.invoke, ps_command.app) @pytest.fixture(scope='function') def initialized(plus_sync): def initialized(plus_sync_cmd): # remove config file if it exists Path('plus_sync.toml').unlink(missing_ok=True) # remove data folder recursively if it exists if Path('data_synced').exists(): Path('data_synced').rmdir() result = plus_sync(['init'], input='test\n') shutil.rmtree('data_synced') result = plus_sync_cmd(['init'], input='test\n') assert result.exit_code == 0 assert 'Done' in result.stdout Loading
plus_sync/cmd/commands/list_subjects.py +9 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,20 @@ import typer from ...config import Config from ..app import app from ..helpers.typer import get_hashed_default @app.command() def list_subjects( remote_name: Annotated[str, typer.Argument(help='The name of the remote')], hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True, hash_subject_ids: Annotated[ bool, typer.Option( help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.', default_factory=get_hashed_default, show_default=False, ), ], ): """ List the subjects in a sync endpoint. Loading
plus_sync/cmd/commands/ls.py +9 −1 Original line number Diff line number Diff line Loading @@ -4,12 +4,20 @@ import typer from ...config import Config from ..app import app from ..helpers.typer import get_hashed_default @app.command(no_args_is_help=True) def ls( remote_name: Annotated[str, typer.Argument(help='The name of the remote to use.')], hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True, hash_subject_ids: Annotated[ bool, typer.Option( help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.', default_factory=get_hashed_default, show_default=False, ), ], ): """ List the files that are available. Loading
plus_sync/cmd/commands/sync.py +9 −1 Original line number Diff line number Diff line Loading @@ -6,12 +6,20 @@ from tqdm import tqdm from ...config import Config from ..app import app from ..helpers.typer import get_hashed_default @app.command(no_args_is_help=True) def sync( remote_name: Annotated[str, typer.Argument(help='The name of the remote to use.')], hash_subject_ids: Annotated[bool, typer.Option(help='Whether to hash the subject IDs.')] = True, hash_subject_ids: Annotated[ bool, typer.Option( help='Whether to hash the subject IDs. Overrides the `has_subject_ids` setting.', default_factory=get_hashed_default, show_default=False, ), ], dry_run: Annotated[bool, typer.Option(help='Whether to do a dry run.')] = False, limit: Annotated[int, typer.Option(help='Limit the number of subjects to sync.')] = None, ): Loading
plus_sync/cmd/helpers/typer.py 0 → 100644 +6 −0 Original line number Diff line number Diff line from plus_sync.config import Config def get_hashed_default() -> bool: config = Config.from_cmdargs() return config.hash_subject_ids