Skip to content

Conversation

@CodeRishiX
Copy link
Contributor

@CodeRishiX CodeRishiX commented Dec 3, 2025

Closes #14361

This draft PR starts adding CLI support for citation key customization.
Work in progress.
I will continue adding the remaining options step-by-step.

Currently, I added the first option:
--pattern: override default citation key pattern (e.g., [auth][year]). Not fully optimized yet.
More CLI options from CitationKeyPatternPreferences will be added next.

Steps to test

:jabkit:run --args="citationkeys generate --input=C:\git-repositories\jabref\jablib\src\main\resources\Chocolate.bib --pattern='[auth][year]'"

No GUI settings are modified — this only affects the current CLI run

Mandatory checks

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 3, 2025
@Option(names = "--output", description = "The output .bib file.")
private Path outputFile;

@Option(
Copy link
Member

Choose a reason for hiding this comment

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

Please implement as a subcommand. We need to keep some hierarchy to keep JabRef and all of its features manageable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay thanks for suggesting .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@calixtus
Thanks again for the guidance. I followed your suggestion and tried to update the hierarchy accordingly. Could you please check if it looks correct now and let me know if I should adjust anything before I continue adding the remaining parts?​

README.md Outdated
@@ -1,4 +1,4 @@
# JabRef Bibliography Management [![APIdia](https://apidia.net/java/JabRef/main/badge.svg)](https://apidia.net/java/JabRef/main)
# JabRef Bibliography Management [![APIdia](https://apidia.net/java/JabRef/main/badge.svg)](https://apidia.net/java/JabRef/main)
Copy link
Member

Choose a reason for hiding this comment

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

This change seems unrelated to your PR. Please undo.

CitationKeyGenerator keyGenerator = new CitationKeyGenerator(
databaseContext,
argumentProcessor.cliPreferences.getCitationKeyPatternPreferences());
prefs);
Copy link
Member

Choose a reason for hiding this comment

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

We do not use abbreviations.

System.out.println(Localization.lang("Regenerating citation keys according to metadata."));
}

var prefs = argumentProcessor.cliPreferences.getCitationKeyPatternPreferences();
Copy link
Member

Choose a reason for hiding this comment

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

We do not use abbreviations.

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 4, 2025

For any inquiries, feel free to [contact ProductMap.ai](https://product-map.ai).

<!-- markdownlint-disable-file MD060 -->
Copy link
Member

Choose a reason for hiding this comment

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


@Command(
name = "citationkeys",
description = "Manage citation key operations.",
Copy link
Member

Choose a reason for hiding this comment

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

I think, this is not a good text. Maybe just remove it.

test.bib Outdated
@@ -0,0 +1,12 @@
@article{dummy,
Copy link
Member

Choose a reason for hiding this comment

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

Please use src/main/resources/Chocolate.bib instead of putting a .bib file in the root of the repository.

@koppor koppor added the status: changes-required Pull requests that are not yet complete label Dec 4, 2025
@CodeRishiX
Copy link
Contributor Author

CodeRishiX commented Dec 6, 2025

@koppor @calixtus Fixed all review comments as suggested - removed CitationKeyCommands description, deleted test.bib, and resolved README changes.

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 6, 2025
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Some comments; I don't know What is left todo - the PR is flagged as "draft"

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 7, 2025
@koppor
Copy link
Member

koppor commented Dec 7, 2025

Not fully optimized yet.

Please work on this. See the screenshot at #14361.

@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 9, 2025
@CodeRishiX
Copy link
Contributor Author

@calixtus @koppor
Hi!
I’ve implemented all parameters of CitationKeyPatternPreferences in the CLI except the per-entry-type patterns.

CitationKeyPatternPreferences supports type-specific patterns , but JabKit’s GlobalCitationKeyPatterns currently applies only a single default pattern and does not support per-entry-type overrides.

public class GlobalCitationKeyPatterns extends AbstractCitationKeyPatterns {

public GlobalCitationKeyPatterns(CitationKeyPattern defaultPattern) {
    this.defaultPattern = defaultPattern;
}

public static GlobalCitationKeyPatterns fromPattern(String pattern) {
    return new GlobalCitationKeyPatterns(new CitationKeyPattern(pattern));
}

@Override
public CitationKeyPattern getLastLevelCitationKeyPattern(EntryType entryType) {
    return defaultPattern;
}

Because of this mismatch, I’ve kept keyPatterns unchanged for now until your guidance.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable parameters for CLI: generate-citation-keys

3 participants