Skip to content

CLI Publish Resource

CLIPublishResource(cli)

Bases: BaseCLIResource

CLI resource for Obsidian Publish 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

open(path=None) async

Open a file on the published site.

Parameters:

Name Type Description Default
path str | None

Path to the file to open. If None, opens the site root.

None
Source code in src/aiobsidian/cli/publish.py
async def open(self, path: str | None = None) -> None:
    """Open a file on the published site.

    Args:
        path: Path to the file to open. If ``None``, opens the
            site root.
    """
    params = {"path": path} if path is not None else None
    await self._cli._execute("publish:open", params=params)

site() async

Get Publish site information.

Returns:

Type Description
dict[str, Any]

Site configuration details.

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

    Returns:
        Site configuration details.
    """
    output = await self._cli._execute("publish:site")
    result: dict[str, Any] = json.loads(output)
    return result

status(path=None) async

Get publication status.

Parameters:

Name Type Description Default
path str | None

Optional file path to check status for.

None

Returns:

Type Description
dict[str, Any]

Publication status details.

Source code in src/aiobsidian/cli/publish.py
async def status(self, path: str | None = None) -> dict[str, Any]:
    """Get publication status.

    Args:
        path: Optional file path to check status for.

    Returns:
        Publication status details.
    """
    params = {"path": path} if path is not None else None
    output = await self._cli._execute("publish:status", params=params)
    result: dict[str, Any] = json.loads(output)
    return result

add(path=None) async

Publish a file or all changed files.

Parameters:

Name Type Description Default
path str | None

Path to the file to publish. If None, publishes all changed files.

None
Source code in src/aiobsidian/cli/publish.py
async def add(self, path: str | None = None) -> None:
    """Publish a file or all changed files.

    Args:
        path: Path to the file to publish. If ``None``, publishes
            all changed files.
    """
    params = {"path": path} if path is not None else None
    await self._cli._execute("publish:add", params=params)

remove(path) async

Unpublish a file.

Parameters:

Name Type Description Default
path str

Path to the file to unpublish.

required
Source code in src/aiobsidian/cli/publish.py
async def remove(self, path: str) -> None:
    """Unpublish a file.

    Args:
        path: Path to the file to unpublish.
    """
    await self._cli._execute("publish:remove", params={"path": path})

list() async

List published files.

Returns:

Type Description
list[dict[str, Any]]

List of published file objects.

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

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