From 38ff163effc82940f0a0e7789557a2cf97429663 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Tue, 13 Feb 2024 09:24:22 +0100 Subject: [PATCH] docs --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index ef5bcfe..e9288ec 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,35 @@ # Markdown Query MDQ is a command line tool to query markdown documents which have yaml frontmatter. + +## Usage +Usage: `mdq [OPTIONS] ` + +### Options +| Option | Description | +|---|---| +| `-j, --json` | Output result as JSON | +| `-l, --limit ` | Limit number of results returned [default: 0] | +| `--offset ` | Offset results by a factor. Useful when used with `--limit` [default: 0] | +| `-f, --filter ` | Filter to apply to the documents. See filter section below. | +| `-c, --column ` | Specify output columns. You can rename the text displayed in the header using the `:` character like this: `VariableName:OutputName` [default: file.title:Title] | +| `-s, --sortby ` | Sort results based on specified key | +| `-g, --groupby ` | Group results based on specified key | +| `-r, --reverse` | Reverse the results | +| `--noheader` | Dont print header in CSV mode. Useful for scripting | +| `--ignoretags` | Dont search for and add inline `#tags` to tags frontmatter | + +## Filters +You can query your document using filters. MDQ uses [jsonfilter](https://git.hydrar.de/jmarya/jsonfilter), so you can query similiar to the `find()` function of MongoDB. + +Examples: +```shell +# Select documents with version 1.0 +mdq -c file.title:Title -f '{"version": "1.0"}' ./docs + +# Select documents which are high priority and assigned to me +mdq -c file.title:Title -f '{"priority": "high"}' -f '{"assigned": "me"}' ./docs + +# Select documents which are assigned to names starting with A or B +mdq -c file.title:Title -f '{"$or": [{"assigned": {"$regex": "^A"}}, {"assigned": {"$regex": "^B}}]}' ./docs +``` \ No newline at end of file