fix panic with '.' as dir arg
This commit is contained in:
parent
38ff163eff
commit
7be5c026b0
2 changed files with 19 additions and 12 deletions
|
@ -7,7 +7,7 @@ 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] |
|
||||
|
|
|
@ -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