Skip to content

CLI Properties Resource

CLIPropertiesResource(cli)

Bases: BaseCLIResource

CLI resource for note property 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

list(path) async

List all properties of a note.

Parameters:

Name Type Description Default
path str

Path to the note relative to the vault root.

required

Returns:

Type Description
dict[str, Any]

Dictionary of property names to their values.

Source code in src/aiobsidian/cli/properties.py
async def list(self, path: str) -> dict[str, Any]:
    """List all properties of a note.

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

    Returns:
        Dictionary of property names to their values.
    """
    output = await self._cli._execute("properties", params={"path": path})
    result: dict[str, Any] = json.loads(output)
    return result

read(path, property_name) async

Read a single property from a note.

Parameters:

Name Type Description Default
path str

Path to the note relative to the vault root.

required
property_name str

Name of the property to read.

required

Returns:

Type Description
Any

The property value.

Source code in src/aiobsidian/cli/properties.py
async def read(self, path: str, property_name: str) -> Any:
    """Read a single property from a note.

    Args:
        path: Path to the note relative to the vault root.
        property_name: Name of the property to read.

    Returns:
        The property value.
    """
    output = await self._cli._execute(
        "property:read",
        params={"path": path, "property": property_name},
    )
    return json.loads(output)

set(path, property_name, value) async

Set a property on a note.

Parameters:

Name Type Description Default
path str

Path to the note relative to the vault root.

required
property_name str

Name of the property to set.

required
value str

Value to set.

required
Source code in src/aiobsidian/cli/properties.py
async def set(self, path: str, property_name: str, value: str) -> None:
    """Set a property on a note.

    Args:
        path: Path to the note relative to the vault root.
        property_name: Name of the property to set.
        value: Value to set.
    """
    await self._cli._execute(
        "property:set",
        params={
            "path": path,
            "property": property_name,
            "value": value,
        },
    )

remove(path, property_name) async

Remove a property from a note.

Parameters:

Name Type Description Default
path str

Path to the note relative to the vault root.

required
property_name str

Name of the property to remove.

required
Source code in src/aiobsidian/cli/properties.py
async def remove(self, path: str, property_name: str) -> None:
    """Remove a property from a note.

    Args:
        path: Path to the note relative to the vault root.
        property_name: Name of the property to remove.
    """
    await self._cli._execute(
        "property:remove",
        params={"path": path, "property": property_name},
    )