fix panic with '.' as dir arg
This commit is contained in:
parent
38ff163eff
commit
7be5c026b0
2 changed files with 19 additions and 12 deletions
22
README.md
22
README.md
|
@ -6,18 +6,18 @@ MDQ is a command line tool to query markdown documents which have yaml frontmatt
|
||||||
Usage: `mdq [OPTIONS] <dir>`
|
Usage: `mdq [OPTIONS] <dir>`
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
|---|---|
|
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `-j, --json` | Output result as JSON |
|
| `-j, --json` | Output result as JSON |
|
||||||
| `-l, --limit <LIMIT>` | Limit number of results returned [default: 0] |
|
| `-l, --limit <LIMIT>` | Limit number of results returned [default: 0] |
|
||||||
| `--offset <OFFSET>` | Offset results by a factor. Useful when used with `--limit` [default: 0] |
|
| `--offset <OFFSET>` | Offset results by a factor. Useful when used with `--limit` [default: 0] |
|
||||||
| `-f, --filter <FILTER>` | Filter to apply to the documents. See filter section below. |
|
| `-f, --filter <FILTER>` | Filter to apply to the documents. See filter section below. |
|
||||||
| `-c, --column <COLUMN>` | Specify output columns. You can rename the text displayed in the header using the `:` character like this: `VariableName:OutputName` [default: file.title:Title] |
|
| `-c, --column <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 <KEY>` | Sort results based on specified key |
|
| `-s, --sortby <KEY>` | Sort results based on specified key |
|
||||||
| `-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 |
|
| `--ignoretags` | Dont search for and add inline `#tags` to tags 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.
|
||||||
|
|
|
@ -13,7 +13,14 @@ fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let args = args::get_args();
|
let args = args::get_args();
|
||||||
|
|
||||||
let mut i = Index::new(&args.root_dir, args.ignoretags);
|
let root_dir = if args.root_dir == "." {
|
||||||
|
let cwd = std::env::current_dir().unwrap();
|
||||||
|
cwd.to_str().unwrap().to_string()
|
||||||
|
} else {
|
||||||
|
args.root_dir
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut i = Index::new(&root_dir, args.ignoretags);
|
||||||
if !args.filters.is_null() {
|
if !args.filters.is_null() {
|
||||||
i = i.filter_documents(&args.filters);
|
i = i.filter_documents(&args.filters);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue