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>`
|
||||
|
||||
### Options
|
||||
| Option | Description |
|
||||
|---|---|
|
||||
| `-j, --json` | Output result as JSON |
|
||||
| `-l, --limit <LIMIT>` | Limit number of results returned [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. |
|
||||
| Option | Description |
|
||||
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `-j, --json` | Output result as JSON |
|
||||
| `-l, --limit <LIMIT>` | Limit number of results returned [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. |
|
||||
| `-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 |
|
||||
| `-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 |
|
||||
| `-s, --sortby <KEY>` | Sort results based on specified key |
|
||||
| `-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 |
|
||||
|
||||
## 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.
|
||||
|
|
|
@ -13,7 +13,14 @@ fn main() {
|
|||
env_logger::init();
|
||||
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() {
|
||||
i = i.filter_documents(&args.filters);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue