Skip to content

feat: add --entry-type-pattern option to citationkeys generate command#15072

Merged
calixtus merged 12 commits into
JabRef:mainfrom
DawydowGerman:enable-configuration-of-citation-key-patterns-at-the-CLI
Mar 9, 2026
Merged

feat: add --entry-type-pattern option to citationkeys generate command#15072
calixtus merged 12 commits into
JabRef:mainfrom
DawydowGerman:enable-configuration-of-citation-key-patterns-at-the-CLI

Conversation

@DawydowGerman

@DawydowGerman DawydowGerman commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Closes #14707

Added --key-patterns option to the citationkeys generate command which allows users to set a key pattern for a specific entry type.

Steps to test

  1. Test verifies --key-patterns option appears in --help:
./gradlew :jabkit:run --args="citationkeys generate --help"

Output:
test1

1.1. Create the next bib file:
@Article{,
author = {Author0},
title = {Title0},
year = {2024},
publisher = {Publisher0},
}

@book{,
author = {Author1},
title = {Title1},
year = {2025},
publisher = {Publisher1},
}

@booklet{,
author = {Author2},
title = {Title2},
year = {2026},
publisher = {Publisher2},
}

  1. Test verifies that given type patterns for specified entry types generate corresponding citation keys:
{
  ./gradlew :jabkit:run --args="citationkeys generate \
    --input /home/german/IdeaProjects/jabref/test.bib \
    --output /home/german/IdeaProjects/jabref/result.bib \
    --key-patterns article='[auth:abbr]_[year]' \
    --key-patterns book='[year][auth]' \
   --key-patterns booklet='[year]_[auth:lower]'"
  cat /home/german/IdeaProjects/jabref/result.bib
}

Output:
test2

  1. Test verifies that other type patterns for specified entry types generate corresponding citation keys:
{
  ./gradlew :jabkit:run --args="citationkeys generate \
    --input /home/german/IdeaProjects/jabref/test.bib \
    --output /home/german/IdeaProjects/jabref/result.bib \
    --key-patterns article='[auth:lower]__[year]' \
    --key-patterns book='[auth:upper]__[year]' \
    --key-patterns booklet='[year]_[auth:upper]'"
  cat /home/german/IdeaProjects/jabref/result.bib
}

Output:
test3

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number.
  • I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

* Add typePatterns field
* Add prepareKeyPatterns method
* Add prepareKeyPatterns method call in CitationKeyPatternPreferences constructor call in getCitationKeyGenerator method

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add --entry-type-pattern option for per-type citation key configuration

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Add --entry-type-pattern CLI option to configure citation key patterns per entry type
• Allow users to override default patterns for specific entry types (article, book, etc.)
• Implement prepareKeyPatterns() method to merge CLI patterns with existing preferences
• Support multiple entry type pattern configurations in single command invocation
Diagram
flowchart LR
  CLI["CLI --entry-type-pattern option"] -- "parsed as Map" --> typePatterns["typePatterns field"]
  typePatterns -- "prepareKeyPatterns method" --> keyPatterns["GlobalCitationKeyPatterns"]
  keyPatterns -- "merged with existing" --> preferences["CitationKeyPatternPreferences"]
  preferences -- "used by" --> generator["CitationKeyGenerator"]
Loading

Grey Divider

File Changes

1. jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java ✨ Enhancement +15/-1

Add entry type pattern CLI option and merge logic

• Added typePatterns field to store entry type pattern mappings from CLI option
• Added --entry-type-pattern option annotation to accept multiple pattern configurations
• Implemented prepareKeyPatterns() method to merge CLI patterns into existing key patterns
• Modified citation key generator initialization to use merged patterns when CLI option provided
• Added imports for Map, GlobalCitationKeyPatterns, and EntryTypeFactory

jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java


Grey Divider

Qodo Logo

@github-actions github-actions Bot added the good second issue Issues that involve a tour of two or three interweaved components in JabRef label Feb 9, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (1)

Grey Divider


Action required

1. --suffix lacks enum converter📎 Requirement gap ✓ Correctness
Description
• The --suffix CLI option is bound directly to the enum CitationKeyPatternPreferences.KeySuffix
without using CaseInsensitiveEnumConverter. • This makes enum parsing likely case-sensitive, so
inputs like always may fail even though they are semantically valid. • This violates the
requirement that enum-valued CLI parameters must be accepted case-insensitively.
Code

jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[1]

@Option(names = "--generate-before-saving", description = "Generate citation keys before saving")
Evidence
Compliance ID 10 requires enum-valued CLI options to use CaseInsensitiveEnumConverter (or
equivalent). The --suffix option is an enum option but has no converter configured in its
@Option annotation.

Use CaseInsensitiveEnumConverter for enum-valued CLI parameters
jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[52-54]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The CLI option `--suffix` is enum-valued but does not use `CaseInsensitiveEnumConverter`, so enum values are likely case-sensitive.
## Issue Context
Compliance requires case-insensitive parsing for enum-valued CLI parameters for `CitationKeyPatternPreferences`.
## Fix Focus Areas
- jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[52-54]
- jabkit/src/main/java/org/jabref/toolkit/converter/CaseInsensitiveEnumConverter.java[1-999999]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. --entry-type-pattern unvalidated types📘 Rule violation ⛨ Security
Description
• The CLI-provided typePatterns keys are passed directly into EntryTypeFactory.parse(type) with
no validation or error handling. • Invalid/unknown entry types can trigger an exception during
execution, potentially resulting in an abrupt failure and leaking internal details (e.g., stack
traces) to the user. • External input should be validated and failures should produce a controlled,
user-friendly message.
Code

jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[R135-140]

+    private GlobalCitationKeyPatterns prepareKeyPatterns(CitationKeyPatternPreferences existingPreferences) {
+        GlobalCitationKeyPatterns keyPatterns = existingPreferences.getKeyPatterns();
+        typePatterns.forEach((type, pattern) -> {
+            keyPatterns.addCitationKeyPattern(EntryTypeFactory.parse(type), pattern);
+        });
+        return keyPatterns;
Evidence
Compliance requires validating external/user-provided inputs and handling errors robustly without
exposing internal details. The new map option values are user-controlled, but the code parses entry
types without guarding against invalid values or reporting actionable errors.

Rule 3: Generic: Robust Error Handling and Edge Case Management
Rule 4: Generic: Secure Error Handling
jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[135-140]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`--entry-type-pattern` accepts user-provided entry type names, but these are parsed via `EntryTypeFactory.parse(type)` without validation or error handling. Invalid values can crash execution and may expose internal exception details.
## Issue Context
The option is external input. Compliance requires explicit validation/edge-case handling and secure, user-friendly error messages.
## Fix Focus Areas
- jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[135-140]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Shared patterns mutated🐞 Bug ✓ Correctness
Description
prepareKeyPatterns retrieves the existing GlobalCitationKeyPatterns from preferences and
mutates it in-place when --entry-type-pattern is used. • Because CitationKeyPatternPreferences
stores and returns the same GlobalCitationKeyPatterns reference (no defensive copy) and
preferences are cached, this modification can leak into other operations/commands executed later in
the same JVM. • This creates surprising, non-local behavior and makes repeated invocations in the
same process depend on previous runs’ CLI arguments.
Code

jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[R135-140]

+    private GlobalCitationKeyPatterns prepareKeyPatterns(CitationKeyPatternPreferences existingPreferences) {
+        GlobalCitationKeyPatterns keyPatterns = existingPreferences.getKeyPatterns();
+        typePatterns.forEach((type, pattern) -> {
+            keyPatterns.addCitationKeyPattern(EntryTypeFactory.parse(type), pattern);
+        });
+        return keyPatterns;
Evidence
The PR code mutates existingPreferences.getKeyPatterns() directly. CitationKeyPatternPreferences
holds this object by reference and exposes it via getKeyPatterns(), while
AbstractCitationKeyPatterns is backed by a mutable HashMap. Additionally, JabRefCliPreferences
caches the CitationKeyPatternPreferences instance, so the same GlobalCitationKeyPatterns
instance is reused within the process—meaning the mutation is a shared side effect.

jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[135-140]
jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyPatternPreferences.java[33-57]
jablib/src/main/java/org/jabref/logic/citationkeypattern/CitationKeyPatternPreferences.java[181-183]
jablib/src/main/java/org/jabref/logic/citationkeypattern/AbstractCitationKeyPatterns.java[17-23]
jablib/src/main/java/org/jabref/logic/preferences/JabRefCliPreferences.java[1500-1516]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`--entry-type-pattern` currently mutates the globally cached `GlobalCitationKeyPatterns` instance (`existingPreferences.getKeyPatterns()`) in-place. This introduces shared-state side effects for the remainder of the JVM process.
### Issue Context
`CitationKeyPatternPreferences` stores and returns the `GlobalCitationKeyPatterns` by reference, and `JabRefCliPreferences` caches the `CitationKeyPatternPreferences` instance. Therefore, mutating the returned patterns object affects all other consumers in-process.
### Fix Focus Areas
- jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java[119-141]
### Suggested implementation approach
- Create a new `GlobalCitationKeyPatterns` instance initialized with the existing default pattern.
- Copy existing per-type overrides from `existingPreferences.getKeyPatterns()` into the new instance.
- Apply `typePatterns` on the new instance.
- Return/use the new instance (do **not** modify the original).
Pseudo-code sketch:

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Comment thread jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java Outdated
Comment thread jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java Outdated
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Feb 9, 2026
@testlens-app

This comment has been minimized.

@Siedlerchr

Copy link
Copy Markdown
Member

Please add a changelog entry

DawydowGerman and others added 2 commits February 10, 2026 14:59
* Add description of the feature in CHANGELOG.md

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

private GlobalCitationKeyPatterns prepareKeyPatterns(CitationKeyPatternPreferences existingPreferences) {
GlobalCitationKeyPatterns keyPatterns = existingPreferences.getKeyPatterns();
typePatterns.forEach((type, pattern) -> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass this as parameter please.

return new CitationKeyGenerator(databaseContext, preferencesToUse);
}

private GlobalCitationKeyPatterns prepareKeyPatterns(CitationKeyPatternPreferences existingPreferences) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass GlobalCitationKeyPatterns keyPatterns as parameter - not the whole preferences.

Alternatively, you can do

prepareKeyPatterns(typePatterns, existingPreferences.getKeyPatterns())

and do @Nullable Map<...> typePatterns

and do and if and return erly.

Also Add JavaDoc -- Reason: I cannot see at the code why pattern is different from typePatterns

private Boolean generateBeforeSaving;

@Option(names = "--entry-type-pattern", description = "Set a key pattern for a specific entry type")
private Map<String, String> typePatterns;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you opt for typePatterns and not for keyPatterns as the preference getter suggests?

https://docs.jabref.org/setup/citationkeypatterns also talks about "key pattern"

@Option(names = "--generate-before-saving", description = "Generate citation keys before saving")
private Boolean generateBeforeSaving;

@Option(names = "--entry-type-pattern", description = "Set a key pattern for a specific entry type")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Option(names = "--entry-type-pattern", description = "Set a key pattern for a specific entry type")
@Option(names = "--key-patterns", description = "Key patterns for specific entry types")

* Refactor prepareKeyPatterns method by replacing existingPreferences parameter with two other parameters
* Add null check of keyPatternsOption parameter
* Add Javadoc for prepareKeyPatterns method
* Perlace ternary expression in getCitationKeyGenerator method by prepareKeyPatterns method call
* Perlace typePatterns field's name for keyPatterns, and --entry-type-pattern option name for --key-patterns

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
koppor
koppor previously requested changes Feb 12, 2026
Comment thread CHANGELOG.md Outdated
- We added the option to enable/disable the HTTP-Server for the browser extension to the Quick Settings on the Welcome screen [#14902](https://github.com/JabRef/jabref/issues/14902)
- We added the ability to update bibliographic information based on the existing entry data. [#14185](https://github.com/JabRef/jabref/issues/14185)
- We added an option to clear [groups with explicitly selected entries](https://docs.jabref.org/finding-sorting-and-cleaning-entries/groups#explicit-selection). [#15001](https://github.com/JabRef/jabref/issues/15001)
- We added --entry-type-pattern option to CLI parameters to allows users to set a citation key's pattern for a specific entry type. [#14707](https://github.com/JabRef/jabref/issues/14707)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency.

Suggested change
- We added --entry-type-pattern option to CLI parameters to allows users to set a citation key's pattern for a specific entry type. [#14707](https://github.com/JabRef/jabref/issues/14707)
- We added `--key-patterns` option to CLI parameters to allows users to set a citation key's pattern for a specific entry type. [#14707](https://github.com/JabRef/jabref/issues/14707)

@github-actions

Copy link
Copy Markdown
Contributor

Your pull request conflicts with the target branch.

Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line.

DawydowGerman and others added 2 commits February 17, 2026 20:03
* Refactor changelog entry to match changed option name

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
@github-actions github-actions Bot added status: no-bot-comments and removed status: changes-required Pull requests that are not yet complete labels Feb 17, 2026
@DawydowGerman DawydowGerman requested a review from koppor February 22, 2026 05:35
/// @param keyPatternsOption patterns submitted by a user via --key-patterns option
/// @param keyPatternsPreferences patterns from preferences
/// @return keyPatterns from preferences or overridden by user-supplied patterns
private GlobalCitationKeyPatterns prepareKeyPatterns(@Nullable Map<String, String> keyPatternsOption, GlobalCitationKeyPatterns keyPatternsPreferences) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"prepare" doesn't hint that something is being returned. Can you think of a better name for this method?

@DawydowGerman DawydowGerman Mar 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that simple 'get' is more suitable.

'getKeyPatterns'.

@subhramit, do you accept this option?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getX by convention doesn't take parameters, but I am okay with it. It's more of a nitpick.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "parse"?

@DawydowGerman DawydowGerman requested a review from subhramit March 3, 2026 06:35
DawydowGerman and others added 2 commits March 4, 2026 08:21
* Change prepareKeyPatterns method's name to getKeyPatterns to highlight that something is being returned by this method

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
@testlens-app

This comment has been minimized.

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels Mar 4, 2026
* Move changelog entry the Unreleased section

---------
@testlens-app

This comment has been minimized.

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Mar 4, 2026
@calixtus

calixtus commented Mar 6, 2026

Copy link
Copy Markdown
Member

Can you please comment on qodos comments? #15072 (comment)

@DawydowGerman

Copy link
Copy Markdown
Contributor Author

@calixtus, yes.

I'll leave a comment on the first required action here since cannot leave a reply to the bot's code review message.

  1. --suffix lacks enum converter.

As the bot suggested, --suffix CLI option doesn't work with lowercase arguments. It makes sense to add the converter class to this option.

@DawydowGerman

Copy link
Copy Markdown
Contributor Author

Do I need to provide solutions for these 3 required actions?

@calixtus

calixtus commented Mar 6, 2026

Copy link
Copy Markdown
Member

See if you can make a simple Converter for 1 and a copy of the keypatterns for 3 to avoid future side effects by uknowing contributors.
About 2: A simple infomessage about fallback to default should be sufficient.

…defensive copy

* Add converter to '--suffix' CLI option for lowercase arguments
* Add inform message if a user passed invalid entry type
* Add defensive copy for the keyPatternsPreferences variable

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
@testlens-app

This comment has been minimized.

@github-actions github-actions Bot added status: changes-required Pull requests that are not yet complete and removed status: no-bot-comments labels Mar 9, 2026
@subhramit

Copy link
Copy Markdown
Member

@DawydowGerman please address the failing unit tests on localization

* Add localization key in JabRef_en.properties file for getKeyPatterns method

---------
@testlens-app

This comment has been minimized.

@github-actions github-actions Bot added status: no-bot-comments and removed status: changes-required Pull requests that are not yet complete labels Mar 9, 2026
@testlens-app

testlens-app Bot commented Mar 9, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 369954e
▶️ Tests: 10126 executed
⚪️ Checks: 52/52 completed


Learn more about TestLens at testlens.app.

@calixtus calixtus enabled auto-merge March 9, 2026 19:43
@calixtus calixtus added this pull request to the merge queue Mar 9, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Mar 9, 2026
Merged via the queue into JabRef:main with commit 9688956 Mar 9, 2026
61 of 62 checks passed
Comment thread CHANGELOG.md

## [Unreleased]

- We added `--key-patterns` option to CLI parameters to allows users to set a citation key's pattern for a specific entry type. [#14707](https://github.com/JabRef/jabref/issues/14707)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong position in CHANGELOG file...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overlooked. Will do a cleanup commit

Siedlerchr added a commit to statxc/jabref that referenced this pull request Mar 10, 2026
* upstream/main:
  fix jbang (JabRef#15311)
  New Crowdin updates (JabRef#15310)
  Fix exception in ExtractReferences from pdf (JabRef#15308)
  feat: add --entry-type-pattern option to citationkeys generate command (JabRef#15072)
  Fix reflection excpetion, add missing (JabRef#15307)
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 14, 2026
JabRef#15072)

* feat: add --entry-type-pattern option to citationkeys generate command

* Add typePatterns field
* Add prepareKeyPatterns method
* Add prepareKeyPatterns method call in CitationKeyPatternPreferences constructor call in getCitationKeyGenerator method

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* docs: add description in CHANGELOG.md

* Add description of the feature in CHANGELOG.md

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* refactor: change prepareKeyPatterns method, add JavaDoc

* Refactor prepareKeyPatterns method by replacing existingPreferences parameter with two other parameters
* Add null check of keyPatternsOption parameter
* Add Javadoc for prepareKeyPatterns method
* Perlace ternary expression in getCitationKeyGenerator method by prepareKeyPatterns method call
* Perlace typePatterns field's name for keyPatterns, and --entry-type-pattern option name for --key-patterns

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* docs: minor changelog entry edit

* Refactor changelog entry to match changed option name

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* refactor: change method's name

* Change prepareKeyPatterns method's name to getKeyPatterns to highlight that something is being returned by this method

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* docs: minor changelog entry edit

* Move changelog entry the Unreleased section

---------

* refactor: add converter to --suffix, inform message for invalid key, defensive copy

* Add converter to '--suffix' CLI option for lowercase arguments
* Add inform message if a user passed invalid entry type
* Add defensive copy for the keyPatternsPreferences variable

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>

* docs: add localization key

* Add localization key in JabRef_en.properties file for getKeyPatterns method

---------

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 19, 2026
JabRef#15072)

* feat: add --entry-type-pattern option to citationkeys generate command

* Add typePatterns field
* Add prepareKeyPatterns method
* Add prepareKeyPatterns method call in CitationKeyPatternPreferences constructor call in getCitationKeyGenerator method

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* docs: add description in CHANGELOG.md

* Add description of the feature in CHANGELOG.md

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* refactor: change prepareKeyPatterns method, add JavaDoc

* Refactor prepareKeyPatterns method by replacing existingPreferences parameter with two other parameters
* Add null check of keyPatternsOption parameter
* Add Javadoc for prepareKeyPatterns method
* Perlace ternary expression in getCitationKeyGenerator method by prepareKeyPatterns method call
* Perlace typePatterns field's name for keyPatterns, and --entry-type-pattern option name for --key-patterns

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* docs: minor changelog entry edit

* Refactor changelog entry to match changed option name

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* refactor: change method's name

* Change prepareKeyPatterns method's name to getKeyPatterns to highlight that something is being returned by this method

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* docs: minor changelog entry edit

* Move changelog entry the Unreleased section

---------

* refactor: add converter to --suffix, inform message for invalid key, defensive copy

* Add converter to '--suffix' CLI option for lowercase arguments
* Add inform message if a user passed invalid entry type
* Add defensive copy for the keyPatternsPreferences variable

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>

* docs: add localization key

* Add localization key in JabRef_en.properties file for getKeyPatterns method

---------

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
FynnianB pushed a commit to FynnianB/jabref that referenced this pull request Mar 19, 2026
JabRef#15072)

* feat: add --entry-type-pattern option to citationkeys generate command

* Add typePatterns field
* Add prepareKeyPatterns method
* Add prepareKeyPatterns method call in CitationKeyPatternPreferences constructor call in getCitationKeyGenerator method

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* docs: add description in CHANGELOG.md

* Add description of the feature in CHANGELOG.md

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* refactor: change prepareKeyPatterns method, add JavaDoc

* Refactor prepareKeyPatterns method by replacing existingPreferences parameter with two other parameters
* Add null check of keyPatternsOption parameter
* Add Javadoc for prepareKeyPatterns method
* Perlace ternary expression in getCitationKeyGenerator method by prepareKeyPatterns method call
* Perlace typePatterns field's name for keyPatterns, and --entry-type-pattern option name for --key-patterns

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* docs: minor changelog entry edit

* Refactor changelog entry to match changed option name

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>

* refactor: change method's name

* Change prepareKeyPatterns method's name to getKeyPatterns to highlight that something is being returned by this method

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* docs: minor changelog entry edit

* Move changelog entry the Unreleased section

---------

* refactor: add converter to --suffix, inform message for invalid key, defensive copy

* Add converter to '--suffix' CLI option for lowercase arguments
* Add inform message if a user passed invalid entry type
* Add defensive copy for the keyPatternsPreferences variable

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>

* docs: add localization key

* Add localization key in JabRef_en.properties file for getKeyPatterns method

---------

---------

Co-authored-by: Carl Christian Snethlage <calixtus@users.noreply.github.com>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good second issue Issues that involve a tour of two or three interweaved components in JabRef status: no-bot-comments status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable configuration of citation key patterns at the CLI

5 participants