diff --git a/Cargo.lock b/Cargo.lock index f169a0f..528187c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,7 +358,7 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "mdq" -version = "0.2.0" +version = "0.3.0" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index f72d3a7..163824d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mdq" -version = "0.2.0" +version = "0.3.0" edition = "2021" [profile.release] diff --git a/README.md b/README.md index 218b275..4917b84 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Usage: `mdq [OPTIONS] ` | `-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 | +| `-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. diff --git a/src/args.rs b/src/args.rs index dc7f0a5..757162d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -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, pub group_by: Option, 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::("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 "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() } diff --git a/src/lib.rs b/src/lib.rs index 6b4d586..da067be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ type Table = Vec>; 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() diff --git a/src/main.rs b/src/main.rs index 71a582d..b45ec8e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); }