Skip to content

CLI Sync Resource

CLISyncResource(cli)

Bases: BaseCLIResource

CLI resource for Obsidian Sync operations.

Attributes:

Name Type Description
_cli

Reference to the parent ObsidianCLI instance.

Source code in src/aiobsidian/cli/_base.py
def __init__(self, cli: ObsidianCLI) -> None:
    self._cli = cli

toggle(*, on) async

Pause or resume Obsidian Sync.

Parameters:

Name Type Description Default
on bool

If True, resume sync; if False, pause sync.

required
Source code in src/aiobsidian/cli/sync.py
async def toggle(self, *, on: bool) -> None:
    """Pause or resume Obsidian Sync.

    Args:
        on: If ``True``, resume sync; if ``False``, pause sync.
    """
    await self._cli._execute("sync:on" if on else "sync:off")

open() async

Open the Sync history UI.

Source code in src/aiobsidian/cli/sync.py
async def open(self) -> None:
    """Open the Sync history UI."""
    await self._cli._execute("sync:open")

status() async

Get sync status information.

Returns:

Type Description
dict[str, Any]

Sync status details.

Source code in src/aiobsidian/cli/sync.py
async def status(self) -> dict[str, Any]:
    """Get sync status information.

    Returns:
        Sync status details.
    """
    output = await self._cli._execute("sync:status")
    result: dict[str, Any] = json.loads(output)
    return result

history(path) async

List sync version history for a file.

Parameters:

Name Type Description Default
path str

Path to the file relative to the vault root.

required

Returns:

Type Description
list[dict[str, Any]]

List of version objects.

Source code in src/aiobsidian/cli/sync.py
async def history(self, path: str) -> list[dict[str, Any]]:
    """List sync version history for a file.

    Args:
        path: Path to the file relative to the vault root.

    Returns:
        List of version objects.
    """
    output = await self._cli._execute("sync:history", params={"path": path})
    result: list[dict[str, Any]] = json.loads(output)
    return result

read(path, *, version) async

Read a specific sync version of a file.

Parameters:

Name Type Description Default
path str

Path to the file relative to the vault root.

required
version str

Version identifier.

required

Returns:

Type Description
str

File content at the specified version.

Source code in src/aiobsidian/cli/sync.py
async def read(self, path: str, *, version: str) -> str:
    """Read a specific sync version of a file.

    Args:
        path: Path to the file relative to the vault root.
        version: Version identifier.

    Returns:
        File content at the specified version.
    """
    return await self._cli._execute(
        "sync:read", params={"path": path, "version": version}
    )

restore(path, *, version) async

Restore a file to a specific sync version.

Parameters:

Name Type Description Default
path str

Path to the file relative to the vault root.

required
version str

Version identifier to restore.

required
Source code in src/aiobsidian/cli/sync.py
async def restore(self, path: str, *, version: str) -> None:
    """Restore a file to a specific sync version.

    Args:
        path: Path to the file relative to the vault root.
        version: Version identifier to restore.
    """
    await self._cli._execute(
        "sync:restore", params={"path": path, "version": version}
    )

deleted() async

List files deleted via sync.

Returns:

Type Description
list[dict[str, Any]]

List of deleted file objects.

Source code in src/aiobsidian/cli/sync.py
async def deleted(self) -> list[dict[str, Any]]:
    """List files deleted via sync.

    Returns:
        List of deleted file objects.
    """
    output = await self._cli._execute("sync:deleted")
    result: list[dict[str, Any]] = json.loads(output)
    return result