From 49cb131197609ec4a91b337e28c965afb913dec9 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre Date: Fri, 12 Apr 2024 23:38:49 +0200 Subject: [PATCH] Rename new option to --filter-fields-by-entrytype (#13) --- CHANGELOG.md | 10 +++++----- README.md | 9 ++++++++- bibtexautocomplete/core/main.py | 2 +- bibtexautocomplete/core/parser.py | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fddd083..b9e80f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version 1.3.2 - 2024-04-12 -- Add `-b / --by-entrytype` option (issue #13). +- Add `-b --filter-fields-by-entrytype` option (issue [#13](https://github.com/dlesbre/bibtex-autocomplete/issues/13)). - Fix `-c / -C` flags only filtering queries and not results since 1.3.0 - Fix output of some error messages not displaying entry ID @@ -14,7 +14,7 @@ progress bar (hoping to make this even prettier once https://github.com/rsalmei/alive-progress/issues/188 gets resolved) - display source list on a new line in final output -- Fix a new error occurring when checking DOIs (issue #12) +- Fix a new error occurring when checking DOIs (issue [#12](https://github.com/dlesbre/bibtex-autocomplete/issues/12)) - Officially support python 3.12 - Build system change: now using `pyproject.toml` instead of `setup.py` and [ruff](https://github.com/astral-sh/ruff) instead of black, isort and flake8. @@ -46,7 +46,7 @@ - Fix author names with `von` prefix not formatted correctly - Fix author names with capitalized prefix (`De`, `Von`, ...) not formatted correctly - Fix `btac` removing capital-preserving brackets and converting to unicode in - user supplied fields (issue #11). + user supplied fields (issue [#11](https://github.com/dlesbre/bibtex-autocomplete/issues/11)). ## Version 1.2.2 - 2023-11-26 @@ -72,11 +72,11 @@ ## Version 1.1.8 - 2023-02-27 - Add global exception catches to resume work if a single lookup fails -- Fix websites returning invalid URLs leading to errors (issue #8, part 2) +- Fix websites returning invalid URLs leading to errors (issue [#8](https://github.com/dlesbre/bibtex-autocomplete/issues/8), part 2) ## Version 1.1.7 - 2023-02-27 -- Fix trying to decode non-text doi response (issue #8) +- Fix trying to decode non-text doi response (issue [#8](https://github.com/dlesbre/bibtex-autocomplete/issues/8)) - Add entry name to error/warning messages ## Version 1.1.6 - 2023-01-06 diff --git a/README.md b/README.md index 03ed02b..414d449 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,13 @@ regularly. Restrict which fields you wish to autocomplete. Field is a BibTeX field (e.g. `author`, `doi`,...). So if you only wish to add missing DOIs use `-c doi`. +- `-b --filter-fields-by-entrytype ` only add fields that correspond to + the given entry type in bibtex's data model. Disabled by default. `required` + only adds required fields, `optional` adds required and optional fields, and + `all` adds required, optional and non-standard fields (doi, issn and isbn). + A list of required/optional fields by entry type can be found + [on the tex stackexchange](https://tex.stackexchange.com/questions/239042/where-can-we-find-a-list-of-all-available-bibtex-entries-and-the-available-fiel) + - `-w --overwrite ` or `-W --dont-overwrite ` Force overwriting of the selected fields. If using `-W author -W journal` @@ -259,7 +266,7 @@ regularly. default is to override nothing (only complete absent and blank fields). For a more complex example `btac -C doi -w author` means complete all fields - save DOI, and only overwrite author fields + save DOI, and only overwrite author fields. You can also use the `-f` flag to overwrite everything or the `-p` flag to add a prefix to new fields, thus avoiding overwrites. diff --git a/bibtexautocomplete/core/main.py b/bibtexautocomplete/core/main.py index f8e4e77..10acc99 100644 --- a/bibtexautocomplete/core/main.py +++ b/bibtexautocomplete/core/main.py @@ -136,7 +136,7 @@ def main(argv: Optional[List[str]] = None) -> None: fields_to_protect_uppercase=fields_to_protect_uppercase, escape_unicode=args.escape_unicode, diff_mode=args.diff, - filter_by_entrytype=args.by_entrytype, + filter_by_entrytype=args.filter_fields_by_entrytype, ) completer.print_filters() try: diff --git a/bibtexautocomplete/core/parser.py b/bibtexautocomplete/core/parser.py index 8d13173..d46d786 100644 --- a/bibtexautocomplete/core/parser.py +++ b/bibtexautocomplete/core/parser.py @@ -113,7 +113,7 @@ def get_bibfiles(input: Path) -> List[Path]: parser.add_argument("--only-complete", "-c", action="append", default=[], choices=FIELD_NAMES) parser.add_argument("--dont-overwrite", "-W", action="append", default=[], choices=FIELD_NAMES) parser.add_argument("--overwrite", "-w", action="append", default=[], choices=FIELD_NAMES) -parser.add_argument("--by-entrytype", "-b", default="no", choices=["required", "optional", "all"]) +parser.add_argument("--filter-fields-by-entrytype", "-b", default="no", choices=["required", "optional", "all"]) parser.add_argument("--exclude-entry", "-E", action="append", default=[]) parser.add_argument("--only-entry", "-e", action="append", default=[]) @@ -192,7 +192,7 @@ def get_bibfiles(input: Path) -> List[Path]: {FgYellow}-c --only-complete{Reset} {FgGreen}{Reset} Only complete the given fields {FgYellow}-C --dont-complete{Reset} {FgGreen}{Reset} Don't complete the given fields Field is a bibtex field (e.g. 'author', 'doi',...) - {FgYellow}-b --by-entrytype{Reset} {FgGreen}required|optional|all{Reset} Disabled by default + {FgYellow}-b --filter-fields-by-entrytype{Reset} {FgGreen}required|optional|all{Reset} Disabled by default Only add fields defined as part of given entry type by bibtex (e.g. no 'publisher' on '@article'). 'required' only adds required fields, 'optional' adds required and optional, 'all' adds required, optional and