A tool for querying and validating document metadata.
Warning
This is a work in progress and is considered highly experimental.
Note
Ock only targets YAML frontmatter in markdown files.
Documents can be listed as well as metadata retrieved.
Expressions can be used to filter files or fields, as necessary. These expressions are expressed using CUE syntax.
Document metadata is validated against a user-defined schema, expressed in CUE.
By default the definition used for validation is #Metadata
within the
.schema.cue
file.
See the usage section for initializing a default schema.
docker pull ghcr.io/slewiskelly/ock:latest
go install github.com/slewiskelly/ock/cmd/ock@latest
brew install slewiskelly/tap/ock
Tip
For full usage and examples use ock help
or ock <command> --help
.
To initialize a default schema file (.schema.cue
) in the current working
directory:
ock init
With the default contents being:
import "time"
#Metadata: {
title: string
status: #Status
owner: #Owner
reviewed: #Date
tags: [...string]
}
#Status: "archived" | "draft" | "published"
#Date: time.Format(time.RFC3339Date)
#Owner: string
This schema can be changed according to specific needs. See the schema reference for information on how to define a schema.
Note
The #Metadata
definition is (always) used to validate files against.
To retrieve the metadata of a single file:
ock get [flags] <path>
To list all (markdown) files rooted at the given path:
ock list [flags] <path>
To validate files, rooted at the given path, against the schema:
ock vet [flags] <path>