dont search inline tags by default

This commit is contained in:
JMARyA 2024-03-08 13:42:19 +01:00
parent 7be5c026b0
commit 4bb15f3a1d
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
6 changed files with 10 additions and 10 deletions

2
Cargo.lock generated
View file

@ -358,7 +358,7 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]] [[package]]
name = "mdq" name = "mdq"
version = "0.2.0" version = "0.3.0"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "mdq" name = "mdq"
version = "0.2.0" version = "0.3.0"
edition = "2021" edition = "2021"
[profile.release] [profile.release]

View file

@ -17,7 +17,7 @@ Usage: `mdq [OPTIONS] <dir>`
| `-g, --groupby <KEY>` | Group results based on specified key | | `-g, --groupby <KEY>` | Group results based on specified key |
| `-r, --reverse` | Reverse the results | | `-r, --reverse` | Reverse the results |
| `--noheader` | Dont print header in CSV mode. Useful for scripting | | `--noheader` | Dont print header in CSV mode. Useful for scripting |
| `--ignoretags` | Dont search for and add inline `#tags` to tags frontmatter | | `-t, --inline-tags` | Search for inline `#tags` and include them in frontmatter |
## Filters ## 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. 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.

View file

@ -8,7 +8,7 @@ pub struct Args {
pub no_header: bool, pub no_header: bool,
pub limit: usize, pub limit: usize,
pub offset: usize, pub offset: usize,
pub ignoretags: bool, pub use_inline_tags: bool,
pub sort_by: Option<String>, pub sort_by: Option<String>,
pub group_by: Option<String>, pub group_by: Option<String>,
pub reversed: bool, pub reversed: bool,
@ -38,7 +38,7 @@ pub fn get_args() -> Args {
.parse() .parse()
.unwrap_or_else(|e| quit_err(e, "Offset is not a number")); .unwrap_or_else(|e| quit_err(e, "Offset is not a number"));
let ignoretags: bool = args.get_flag("ignoretags"); let use_inline_tags: bool = args.get_flag("inline-tags");
let sort_by = args let sort_by = args
.get_one::<String>("sortby") .get_one::<String>("sortby")
@ -101,7 +101,7 @@ pub fn get_args() -> Args {
no_header, no_header,
limit, limit,
offset, offset,
ignoretags, use_inline_tags,
sort_by, sort_by,
group_by, group_by,
reversed, reversed,
@ -138,6 +138,6 @@ fn get_args_match() -> ArgMatches {
.arg(arg!(-g --groupby <KEY> "Group results based on specified key").required(false)) .arg(arg!(-g --groupby <KEY> "Group results based on specified key").required(false))
.arg(arg!(-r --reverse "Reverse the results").required(false)) .arg(arg!(-r --reverse "Reverse the results").required(false))
.arg(arg!(--noheader "Dont print header in CSV mode. Useful for scripting").required(false)) .arg(arg!(--noheader "Dont print header in CSV mode. Useful for scripting").required(false))
.arg(arg!(--ignoretags "Don't add inline #tags to tags frontmatter").required(false)) .arg(clap::Arg::new("inline-tags").short('t').long("inline-tags").help("Include inline #tags in tags frontmatter").required(false).num_args(0))
.get_matches() .get_matches()
} }

View file

@ -81,7 +81,7 @@ type Table = Vec<Vec<String>>;
impl Index { impl Index {
/// Create a markdown document index over `dir` /// Create a markdown document index over `dir`
pub fn new(dir: &str, ignore_inline_tags: bool) -> Self { pub fn new(dir: &str, inline_tags: bool) -> Self {
let mut i = Self { documents: vec![] }; let mut i = Self { documents: vec![] };
for e in walkdir::WalkDir::new(dir) for e in walkdir::WalkDir::new(dir)
@ -101,7 +101,7 @@ impl Index {
let mut frontmatter: serde_yaml::Value = let mut frontmatter: serde_yaml::Value =
serde_yaml::from_str(&frontmatter).unwrap(); serde_yaml::from_str(&frontmatter).unwrap();
if !ignore_inline_tags { if inline_tags {
let mut tags = frontmatter let mut tags = frontmatter
.as_mapping() .as_mapping()
.unwrap() .unwrap()

View file

@ -20,7 +20,7 @@ fn main() {
args.root_dir args.root_dir
}; };
let mut i = Index::new(&root_dir, args.ignoretags); let mut i = Index::new(&root_dir, args.use_inline_tags);
if !args.filters.is_null() { if !args.filters.is_null() {
i = i.filter_documents(&args.filters); i = i.filter_documents(&args.filters);
} }