Scripting and automation

Last updated

The CLI is built to compose with the rest of your shell. It reads from stdin, prints markdown or JSON, and returns useful exit codes, so it drops into pipes, scripts, and cron jobs.

Piping content in

notes create and notes edit read content from --stdin or --file, so you can feed a note from any other command:

# capture a daily log
printf "# Log\n%s\n" "$(date)" | notate notes create "Daily log" --stdin

# file recent commits as a note
git log --oneline -10 | notate notes create "Recent commits" --stdin --folder Dev

Getting content out

notes get prints raw markdown to stdout, so it pipes into other tools:

notate notes get "Spec" | wc -w
notate notes get "Spec" | pandoc -f markdown -o spec.pdf

JSON for scripts

Add --json to most commands for machine-readable output you can parse with a tool like jq:

# titles of the five most recently updated notes
notate notes list --sort updatedAt --limit 5 --json | jq -r '.[].title'

# the id of a note, to address it unambiguously afterward
id=$(notate notes get "Spec" --json | jq -r '.id')
notate notes tag --id "$id" --add reviewed

Non-interactive use

Destructive commands prompt for confirmation by default. In a script, pass --confirm to skip the prompt and --quiet to suppress non-essential output:

notate notes delete "Old draft" --confirm --quiet

For commands that resolve a note or folder by name, prefer --id in scripts so an ambiguous or renamed title never picks the wrong item.

Shell completion

Install completions so your shell can suggest commands and options:

notate completion zsh >> ~/.zshrc      # then reload your shell
# or: notate completion bash / notate completion fish

Scheduling

Because the CLI is non-interactive with --confirm and stores its credentials in the OS keychain, it works in a cron job or CI step once you have logged in on that machine. For example, a nightly note from another system:

0 18 * * *  some-report --today | notate notes create "Daily report $(date +\%F)" --stdin --folder Reports --quiet

Next: configuration and stored data.