Skip to content

CLI Workspaces Resource

CLIWorkspacesResource(cli)

Bases: BaseCLIResource

CLI resource for workspace management.

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

current() async

Get the current workspace layout tree.

Returns:

Type Description
dict[str, Any]

Current workspace tree structure.

Source code in src/aiobsidian/cli/workspaces.py
async def current(self) -> dict[str, Any]:
    """Get the current workspace layout tree.

    Returns:
        Current workspace tree structure.
    """
    output = await self._cli._execute("workspace")
    result: dict[str, Any] = json.loads(output)
    return result

save(name) async

Save the current workspace layout.

Parameters:

Name Type Description Default
name str

Name for the saved workspace.

required
Source code in src/aiobsidian/cli/workspaces.py
async def save(self, name: str) -> None:
    """Save the current workspace layout.

    Args:
        name: Name for the saved workspace.
    """
    await self._cli._execute("workspace:save", params={"name": name})

load(name) async

Load a saved workspace.

Parameters:

Name Type Description Default
name str

Name of the workspace to load.

required
Source code in src/aiobsidian/cli/workspaces.py
async def load(self, name: str) -> None:
    """Load a saved workspace.

    Args:
        name: Name of the workspace to load.
    """
    await self._cli._execute("workspace:load", params={"name": name})

delete(name) async

Delete a saved workspace.

Parameters:

Name Type Description Default
name str

Name of the workspace to delete.

required
Source code in src/aiobsidian/cli/workspaces.py
async def delete(self, name: str) -> None:
    """Delete a saved workspace.

    Args:
        name: Name of the workspace to delete.
    """
    await self._cli._execute("workspace:delete", params={"name": name})

list() async

List all saved workspaces.

Returns:

Type Description
list[dict[str, Any]]

List of workspace objects.

Source code in src/aiobsidian/cli/workspaces.py
async def list(self) -> list[dict[str, Any]]:
    """List all saved workspaces.

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