Skip to content

Commit

Permalink
Rename new option to --filter-fields-by-entrytype (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlesbre committed Apr 12, 2024
1 parent cea7125 commit 49cb131
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,21 @@ 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 <required|optional|all>` 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 <field>` or `-W --dont-overwrite <field>`

Force overwriting of the selected fields. If using `-W author -W journal`
your force overwrite of all fields except `author` and `journal`. The
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.
Expand Down
2 changes: 1 addition & 1 deletion bibtexautocomplete/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions bibtexautocomplete/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[])
Expand Down Expand Up @@ -192,7 +192,7 @@ def get_bibfiles(input: Path) -> List[Path]:
{FgYellow}-c --only-complete{Reset} {FgGreen}<field>{Reset} Only complete the given fields
{FgYellow}-C --dont-complete{Reset} {FgGreen}<field>{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
Expand Down

0 comments on commit 49cb131

Please sign in to comment.