Feature/14361 enable parameters for cli#14500
Conversation
| @Option(names = "--output", description = "The output .bib file.") | ||
| private Path outputFile; | ||
|
|
||
| @Option( |
There was a problem hiding this comment.
Please implement as a subcommand. We need to keep some hierarchy to keep JabRef and all of its features manageable.
There was a problem hiding this comment.
Okay thanks for suggesting .
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
@CodeRishiX Did you update the screenshot in the PR description?
README.md
Outdated
| @@ -1,4 +1,4 @@ | |||
| # JabRef Bibliography Management [](https://apidia.net/java/JabRef/main) | |||
| # JabRef Bibliography Management [](https://apidia.net/java/JabRef/main) | |||
There was a problem hiding this comment.
This change seems unrelated to your PR. Please undo.
| CitationKeyGenerator keyGenerator = new CitationKeyGenerator( | ||
| databaseContext, | ||
| argumentProcessor.cliPreferences.getCitationKeyPatternPreferences()); | ||
| prefs); |
| System.out.println(Localization.lang("Regenerating citation keys according to metadata.")); | ||
| } | ||
|
|
||
| var prefs = argumentProcessor.cliPreferences.getCitationKeyPatternPreferences(); |
|
|
||
| For any inquiries, feel free to [contact ProductMap.ai](https://product-map.ai). | ||
|
|
||
| <!-- markdownlint-disable-file MD060 --> |
There was a problem hiding this comment.
This change seems to be OK - https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md060---table-column-style
|
|
||
| @Command( | ||
| name = "citationkeys", | ||
| description = "Manage citation key operations.", |
There was a problem hiding this comment.
I think, this is not a good text. Maybe just remove it.
test.bib
Outdated
| @@ -0,0 +1,12 @@ | |||
| @article{dummy, | |||
There was a problem hiding this comment.
Please use src/main/resources/Chocolate.bib instead of putting a .bib file in the root of the repository.
koppor
left a comment
There was a problem hiding this comment.
Some comments; I don't know What is left todo - the PR is flagged as "draft"
|
|
||
| @Override | ||
| public void run() { | ||
| System.out.println("Testing"); |
There was a problem hiding this comment.
This indicates that the PR is sitll draft
jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java
Outdated
Show resolved
Hide resolved
jabkit/src/main/java/org/jabref/toolkit/commands/GenerateCitationKeys.java
Outdated
Show resolved
Hide resolved
Please work on this. See the screenshot at #14361. |
…egex, delimiter, etc.)
…egex, delimiter, etc.)
|
@calixtus @koppor 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 { Because of this mismatch, I’ve kept keyPatterns unchanged for now until your guidance. Thanks! |
| DoiToBibtex.class, | ||
| Fetch.class, | ||
| GenerateBibFromAux.class, | ||
| GenerateCitationKeys.class, |
There was a problem hiding this comment.
This should be noted in "Removed" in CHANGELOG.md
Hi @calixtus I’m not fully sure what you mean by the missing banner here. Do you expect the standard JabKit startup banner to be shown for citationkeys generate, or some explicit output indicating that the command is running/completed? Just want to confirm before implementing. Thanks! |
No banner is OK --> #14664 |
CHANGELOG.md
Outdated
|
|
||
| ### Removed | ||
|
|
||
| - We removed `generate-citation-keys` as a standalone command in JabKit. Use `citationkeys generate` instead. [#14361](https://github.com/JabRef/jabref/issues/14361) |
There was a problem hiding this comment.
Link the PR here, because it is not in the issue.
| @Option(names = "--output", description = "The output .bib file.") | ||
| private Path outputFile; | ||
|
|
||
| @Option( |
There was a problem hiding this comment.
@CodeRishiX Did you update the screenshot in the PR description?
| avoidOverwrite != null ? avoidOverwrite : existingPreferences.shouldAvoidOverwriteCiteKey(), | ||
| warnBeforeOverwrite != null ? warnBeforeOverwrite : existingPreferences.shouldWarnBeforeOverwriteCiteKey(), | ||
| generateBeforeSaving != null ? generateBeforeSaving : existingPreferences.shouldGenerateCiteKeysBeforeSaving(), | ||
| suffix != null ? suffix : existingPreferences.getKeySuffix(), |
There was a problem hiding this comment.
Keep key -- variable should be keySuffix. See other lines. They are consistent (somehow)
| transliterate != null ? transliterate : existingPreferences.shouldTransliterateFieldsForCitationKey(), | ||
| avoidOverwrite != null ? avoidOverwrite : existingPreferences.shouldAvoidOverwriteCiteKey(), | ||
| warnBeforeOverwrite != null ? warnBeforeOverwrite : existingPreferences.shouldWarnBeforeOverwriteCiteKey(), | ||
| generateBeforeSaving != null ? generateBeforeSaving : existingPreferences.shouldGenerateCiteKeysBeforeSaving(), |
…ture/14361-enable-parameters-for-cli
| keyPatternRegex != null ? keyPatternRegex : existingPreferences.getKeyPatternRegex(), | ||
| keyPatternReplacement != null ? keyPatternReplacement : existingPreferences.getKeyPatternReplacement(), | ||
| unwantedCharacters != null ? unwantedCharacters : existingPreferences.getUnwantedCharacters(), | ||
| existingPreferences.getKeyPatterns(), |
There was a problem hiding this comment.
Yes, looks correct to me. keypatterns cannot be overridden in the commandline. would be a funny commandline.
There was a problem hiding this comment.
Yes, looks correct to me. keypatterns cannot be overridden in the commandline. would be a funny commandline.
But it was wished in the issue
Offer each element of CitationKeyPatternPreferences as parameter in the CLI for org.jabref.toolkit.commands.GenerateCitationKeys
Reason: Use on server-side.
There was a problem hiding this comment.
Yes, looks correct to me. keypatterns cannot be overridden in the commandline. would be a funny commandline.
But it was wished in the issue
Offer each element of CitationKeyPatternPreferences as parameter in the CLI for org.jabref.toolkit.commands.GenerateCitationKeys
Reason: Use on server-side.
@koppor I agree , maybe this matches the limitation I mentioned in my comment two weeks ago about keyPatterns and GlobalCitationKeyPatterns,
There was a problem hiding this comment.
Yes, looks correct to me. keypatterns cannot be overridden in the commandline. would be a funny commandline.
But it was wished in the issue
Offer each element of CitationKeyPatternPreferences as parameter in the CLI for org.jabref.toolkit.commands.GenerateCitationKeys
Reason: Use on server-side.
@koppor I agree , maybe this matches the limitation I mentioned in my comment two weeks ago about keyPatterns and GlobalCitationKeyPatterns,
The next contributor will have to think of this. If we dive that deep, we could solve the issue for ourselves. We could then leave out humans and just use AI agents. (And believe me, we are short before doing this 😅).
| transliterate != null ? transliterate : existingPreferences.shouldTransliterateFieldsForCitationKey(), | ||
| avoidOverwrite != null ? avoidOverwrite : existingPreferences.shouldAvoidOverwriteCiteKey(), | ||
| warnBeforeOverwrite != null ? warnBeforeOverwrite : existingPreferences.shouldWarnBeforeOverwriteCiteKey(), | ||
| generateBeforeSaving != null ? generateBeforeSaving : existingPreferences.shouldGenerateCiteKeysBeforeSaving(), |
There was a problem hiding this comment.
The naming is still inconsistent.

Closes #14361
Added customizable parameters to JabKit's citationkeys generate command. Users can now configure citation key generation settings via CLI parameters, matching the customization options available in the JabRef GUI.
Implemented all CitationKeyPatternPreferences options as CLI parameters.
Steps to test
./gradlew :jabkit:run --args="citationkeys generate --help"output :
Shows all citation key options
Confirms subcommand hierarchy
./gradlew :jabkit:run --args="citationkeys generate --input=C:/git-repositories/jabref/jablib/src/main/resources/Chocolate.bib --pattern='[author][year]' --transliterate --warn-before-overwrite --suffix=ALWAYS --regex='[^a-zA-Z0-9]' --regex-replacement='' --keyword-delimiter='_'"No GUI settings are modified — this only affects the current CLI run
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)