Bike CLI – setting a row_created date?

If, in the context of a

bike update rows "$SESSION_ID" --outline "$DOC_PATH"`

call, I add the switch:

--attr data-created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

then in the editor I see a badge (unexpected bonus)

In the XML source, however, I see a duplicate data- prefix:

data-data-created="2026-08-30T13:05:05Z"

If I respond by dropping the data- prefix from the --attr name
(data-created → created)

--attr created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

Then no attribute seems to be created at all:

<li id="yWEvmke_xM_02oOuSfvlh" data-type="unordered">
    <p>Second sample line</p>
</li>

Not sure if this is unexpected, and I may well be getting something wrong :slight_smile:

(perhaps some missing quoting or escaping ?)

Expand disclosure triangle to view zsh source
#!/bin/zsh

POPCLIP_OPTION_DOCUMENT="~/Documents/Inbox.bike"
POPCLIP_OPTION_ROW="/Inbox"
POPCLIP_TEXT=$'Second sample line\nalpha\nbeta\ngamma'
POPCLIP_OPTION_POSITION="start"

setopt extended_glob

DOC_PATH="${POPCLIP_OPTION_DOCUMENT/#\~/$HOME}"

# Spaces, tabs, newlines trimmed from start and end
TRIMMED_TEXT="${POPCLIP_TEXT##[[:space:]]#}"
TRIMMED_TEXT="${TRIMMED_TEXT%%[[:space:]]#}"

# Any indents preserved, all non-empty lines have markdown bullets
BULLETED_TEXT=$(printf "%s" "$TRIMMED_TEXT" | sed -E 's/^([[:blank:]]*)([^[:blank:]-]+)/\1- \2/')

add_rows() {
    # Text of first line, and its session ID, as two lines of text
    NAME_SESSIONID=$(printf "%s\n" "$BULLETED_TEXT" |
        bike create rows -f - --outline "$DOC_PATH" "$@" |
        jaq -r '.[0].text[0].string, .[0].id'
    )
    
    FIRST_ROW_TEXT="${NAME_SESSIONID%$'\n'*}"
    FIRST_CLAUSE="${FIRST_ROW_TEXT%%[.,;:]*}"
    
    SESSION_ID="${NAME_SESSIONID##*$'\n'}"
    
    # Persistent ID of the document
    DOC_ID=$(bike get outline /* --outline "$DOC_PATH" | jaq -r ".persistentId")
    
    BIKE_URL=$(bike update rows "$SESSION_ID" --outline "$DOC_PATH" \
                --attr created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
                --persistent-id @ensure --type unordered |
                jaq -r --arg doc "$DOC_ID" '"bike://\($doc)/#\(.[0].row.persistentId)"')
    
    MD_LINK="[${FIRST_CLAUSE}](${BIKE_URL})"
    
    # Placed in various pasteboard items   
    osascript -l JavaScript -e "
        ObjC.import('AppKit');
        const pb = $.NSPasteboard.generalPasteboard;
        pb.clearContents;
        pb.setStringForType('${FIRST_CLAUSE}', 'public.url-name');
        pb.setStringForType('${BIKE_URL}', 'public.url');
        pb.setStringForType('${MD_LINK}', 'public.utf8-plain-text');
    " > /dev/null
    
    echo "$MD_LINK"
    echo "$NOW"
}

if [[ ! -f "$DOC_PATH" ]]; then
    bike create outline "$DOC_PATH"
fi

if [[ -n "$POPCLIP_OPTION_ROW" ]]; then
    ROW_EXISTS=$(bike get outline --refs "$POPCLIP_OPTION_ROW" --outline "$DOC_PATH" --shape flat -o txt)
    
    # The parent heading created if not found
    if [[ -z "$ROW_EXISTS" ]]; then
        ROW_TEXT="${POPCLIP_OPTION_ROW#/}"
        bike create row --outline "$DOC_PATH" --text "$ROW_TEXT"
    fi
    
    add_rows --parent "$POPCLIP_OPTION_ROW" --position "$POPCLIP_OPTION_POSITION"
else
    add_rows --position "$POPCLIP_OPTION_POSITION"
fi

You are running into a number of issues here. I’m updating next Bike release to give better error messages…

First issue is that data- for attributes names is specific to the bike/html file formats. It’s only an encoding. At runtime the attributes don’t have the data- prefix. So while --attr data-created somewhat worked, you were not setting the created attribute, you were setting the data-created attribute (encoded as data-data-created). And then to confuse things further, on read all those data’s got striped, and then the value was not set because “created” is reserved.

The full set of reserved attributes is:

"id", "text", "type", "created", "modified"

And when you set them the mutation request is ignored and a warning logged. I’m upgrading this to API error for next release. Generally these attributes shouldn’t be set, at least not directly in the current API.


The idea is that generally created/modified are not needed and storing them for every row creates a lot of noise. And is a document level decision (File > Document Info)

For the case of pop clip, maybe use a different attribute name, such as “added”? Then the date would be visible and show a tag?

Let me know what you think. API change is possible too.

1 Like

Thanks – I should have grasped sooner that “created” was reserved.

(and a custom term like added is a much better idea)