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]]
name = "mdq"
version = "0.2.0"
version = "0.3.0"
dependencies = [
"chrono",
"clap",

View file

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

View file

@ -17,7 +17,7 @@ Usage: `mdq [OPTIONS] <dir>`
| `-g, --groupby <KEY>` | 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 |
| `-t, --inline-tags` | Search for inline `#tags` and include them in 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.

View file

@ -8,7 +8,7 @@ pub struct Args {
pub no_header: bool,
pub limit: usize,
pub offset: usize,
pub ignoretags: bool,
pub use_inline_tags: bool,
pub sort_by: Option<String>,
pub group_by: Option<String>,
pub reversed: bool,
@ -38,7 +38,7 @@ pub fn get_args() -> Args {
.parse()
.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
.get_one::<String>("sortby")
@ -101,7 +101,7 @@ pub fn get_args() -> Args {
no_header,
limit,
offset,
ignoretags,
use_inline_tags,
sort_by,
group_by,
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!(-r --reverse "Reverse the results").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()
}

View file

@ -81,7 +81,7 @@ type Table = Vec<Vec<String>>;
impl Index {
/// 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![] };
for e in walkdir::WalkDir::new(dir)
@ -101,7 +101,7 @@ impl Index {
let mut frontmatter: serde_yaml::Value =
serde_yaml::from_str(&frontmatter).unwrap();
if !ignore_inline_tags {
if inline_tags {
let mut tags = frontmatter
.as_mapping()
.unwrap()

View file

@ -20,7 +20,7 @@ fn main() {
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() {
i = i.filter_documents(&args.filters);
}