Skip to content

Commit

Permalink
Options to remove field
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Feb 20, 2024
1 parent 0c9d11b commit 2eb4b87
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions GooseBib/bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,13 @@ def _split_lines(self, text, width):
help='Add field. For all types ``"field"``, only for one type ``typename:field``.',
)

parser.add_argument(
"--remove-field",
type=str,
action="append",
help='Remove field. For all types ``"field"``, only for one type ``typename:field``.',
)

parser.add_argument(
"--no-title",
action="store_true",
Expand Down Expand Up @@ -1371,6 +1378,17 @@ def GbibClean(cli_args: list[str] = None):
for typename in fields:
fields[typename].append(field)

if args.remove_field:
for field in args.remove_field:
if ":" in field:
typename, field = field.split(":")
if field in fields[typename]:
fields[typename].remove(field)
else:
for typename in fields:
if field in fields[typename]:
fields[typename].remove(field)

if args.rename_field:
for oldfield, newfield in args.rename_field:
for typename in fields:
Expand Down

0 comments on commit 2eb4b87

Please sign in to comment.