diff --git a/GooseBib/bibtex.py b/GooseBib/bibtex.py index f95104c..287dd83 100644 --- a/GooseBib/bibtex.py +++ b/GooseBib/bibtex.py @@ -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", @@ -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: