chore!: Rename force option to duplicates

BREAKING CHANGE: Change the `--force/--no-force` cli option to
`--duplicates/--no-duplicates` since it describes a little clearer what
using it actually achieves (adding quote duplicates or not to output).
This commit is contained in:
Marty Oehme 2025-09-11 10:17:53 +02:00
parent 5f01aa1f2b
commit e90a123f88
Signed by: Marty
GPG key ID: 4E535BC19C61886E
4 changed files with 17 additions and 17 deletions

View file

@ -71,8 +71,8 @@ papis.config.register_default_settings(DEFAULT_OPTIONS)
help="Choose which input formats to gather annotations from. [default: all]",
)
@click.option(
"--force/--no-force",
"-f",
"--duplicates/--no-duplicates",
"-d",
help="Do not drop any annotations because they already exist.",
show_default=True,
)
@ -88,7 +88,7 @@ def main(
extractors: list[str],
output: str,
git: bool,
force: bool,
duplicates: bool,
) -> None:
"""Extract annotations from any documents.
@ -118,7 +118,7 @@ def main(
git=git,
formatter=formatter,
extractors=[all_extractors.get(e) for e in extractors],
force=force,
duplicates=duplicates,
)
@ -129,7 +129,7 @@ def run(
edit: bool = False,
write: bool = False,
git: bool = False,
force: bool = False,
duplicates: bool = False,
) -> None:
exporter: Exporter
if write:
@ -137,7 +137,7 @@ def run(
formatter=formatter or formatters["markdown-atx"],
edit=edit,
git=git,
force=force,
duplicates=duplicates,
)
else:
exporter = all_exporters["stdout"](

View file

@ -20,7 +20,7 @@ class Exporter(Protocol):
formatter: Formatter
edit: bool = False
git: bool = False
force: bool = False
duplicates: bool = False
def run(
self, annot_docs: list[tuple[papis.document.Document, list[Annotation]]]

View file

@ -18,7 +18,7 @@ class NotesExporter:
formatter: Formatter
edit: bool = False
git: bool = False
force: bool = False
duplicates: bool = False
def run(self, annot_docs: list[tuple[Document, list[Annotation]]]) -> None:
"""Write annotations into document notes.
@ -33,7 +33,7 @@ class NotesExporter:
doc, annots, first=True
).split("\n")
if formatted_annotations:
self._add_annots_to_note(doc, formatted_annotations, force=self.force)
self._add_annots_to_note(doc, formatted_annotations, duplicates=self.duplicates)
if self.edit:
papis.commands.edit.edit_notes(doc, git=self.git)
@ -43,15 +43,15 @@ class NotesExporter:
document: Document,
formatted_annotations: list[str],
git: bool = False,
force: bool = False,
duplicates: bool = False,
) -> None:
"""
Append new annotations to the end of a note.
This function appends new annotations to the end of a note file. It takes in a
document object containing the note, a list of formatted annotations to be
added, and optional flags git and force. If git is True, the changes will be
committed to git. If force is True, the annotations will be added even if they
added, and optional flags git and duplicates. If git is True, the changes will be
committed to git. If duplicates is True, the annotations will be added even if they
already exist in the note.
:param document: The document object representing the note
@ -60,9 +60,9 @@ class NotesExporter:
:type formatted_annotations: list[str]
:param git: Flag indicating whether to commit changes to git, defaults to False.
:type git: bool, optional
:param force: Flag indicating whether to force adding annotations even if they
already exist, defaults to False.
:type force: bool, optional
:param duplicates: Flag indicating whether to force adding annotations as duplicates
even if they already exist, defaults to False.
:type duplicates: bool, optional
"""
logger.debug("Adding annotations to note.")
notes_path = papis.notes.notes_path_ensured(document)
@ -72,7 +72,7 @@ class NotesExporter:
existing = file_read.readlines()
new_annotations: list[str] = []
if not force:
if not duplicates:
new_annotations = self._drop_existing_annotations(
formatted_annotations, existing
)

View file

@ -11,7 +11,7 @@ class StdoutExporter:
formatter: Formatter
edit: bool = False
git: bool = False
force: bool = False
duplicates: bool = False
def run(self, annot_docs: list[tuple[Document, list[Annotation]]]) -> None:
"""Pretty print annotations to stdout.