Skip to content

nhomble/fmq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fmq

jq for markdown frontmatter.

Install

From releases

Download the latest binary from GitHub Releases.

From source

cargo install --path .

Usage

fmq <expression> [file]
  • If file is omitted, reads from stdin
  • Queries output the result to stdout
  • Mutations output the modified markdown to stdout

Examples

Query

# Get a field
fmq '.title' post.md
# Hello World

# Get nested field
fmq '.author.name' post.md
# Alice

# Get array
fmq '.tags' post.md
# ["rust", "cli"]

# From stdin
cat post.md | fmq '.title'

Mutate

# Set a field
fmq '.title = "New Title"' post.md > updated.md

# Add to array
fmq '.tags += ["new-tag"]' post.md > updated.md

# Delete a field
fmq 'del(.draft)' post.md > updated.md

# Update nested field
fmq '.author.name = "Bob"' post.md > updated.md

Piping

# Query then mutate
fmq '.tags' post.md | jq '.[0]'

# Chain mutations
fmq '.title = "New"' post.md | fmq '.draft = false' > updated.md

About

jq for markdown frontmatter

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages