Skip to content

CLI Tabs Resource

CLITabsResource(cli)

Bases: BaseCLIResource

CLI resource for workspace tabs 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

open(*, file=None, view=None) async

Open a file or view in a new tab.

Parameters:

Name Type Description Default
file str | None

Path to the file to open.

None
view str | None

View type to open.

None
Source code in src/aiobsidian/cli/tabs.py
async def open(self, *, file: str | None = None, view: str | None = None) -> None:
    """Open a file or view in a new tab.

    Args:
        file: Path to the file to open.
        view: View type to open.
    """
    params: dict[str, str] = {}
    if file is not None:
        params["file"] = file
    if view is not None:
        params["view"] = view
    await self._cli._execute("tab:open", params=params or None)

recents() async

List recently opened files.

Returns:

Type Description
list[dict[str, Any]]

List of recently opened file objects.

Source code in src/aiobsidian/cli/tabs.py
async def recents(self) -> list[dict[str, Any]]:
    """List recently opened files.

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

list() async

List open tabs.

Returns:

Type Description
list[dict[str, Any]]

List of open tab objects.

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

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