-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jump to entry key cli (WIP) #659
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments.
Please include it and submit to the main repo
return; | ||
} | ||
} | ||
LOGGER.error("Could not find given citation key to jump to"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOGGER.error("Could not find given citation key to jump to"); | |
LOGGER.error("Could not find citation key {} to jump to", citationKey); |
Here, System.out.println
is OK, because it was a CLI which outputs to the console. Please also add the output to the console. -- Maybe, even replace logger completely:
System.out.println("Could not find citation key %0 in any library", citationKey);
See https://devdocs.jabref.org/code-howtos/localization.html for steps for the localiaztion.
@@ -773,6 +777,18 @@ private Optional<ParserResult> fetch(String fetchCommand) { | |||
} | |||
} | |||
|
|||
private void jumpToEntryKey(List<ParserResult> loaded, String citationKey) { | |||
// search for this key in imported files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line, because the for each loop makes it clear somehow.
@@ -288,6 +296,14 @@ private static Options getOptions() { | |||
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all") | |||
.build()); | |||
|
|||
options.addOption(Option | |||
.builder("j") | |||
.longOpt("jumpToEntryKey") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to jumpToKey
. (We use CitationKey
throughout JabRef. Sometimes also BibtexKey
. Never EntryKey
. With key
you are on the safe side ^^)
options.addOption(Option | ||
.builder("j") | ||
.longOpt("jumpToEntryKey") | ||
.desc(String.format("%s: '%s'", Localization.lang("Jump to the BibEntry of the given key."), "-j key")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.desc(String.format("%s: '%s'", Localization.lang("Jump to the BibEntry of the given key."), "-j key")) | |
.desc(String.format("%s: '%s'", Localization.lang("Jump to the entry of the given citation key."), "-j key")) |
boolean focusDifferent = false; | ||
Optional<BibEntry> focusedEntry = Optional.empty(); | ||
for (ParserResult parserResult : parserResults) { | ||
// Make sure this parser result is its own library instead of imported BibTex entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write "BibTeX" always with capital X
} | ||
if (parserResult.getEntryToFocus().isPresent() && focusDifferent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that be } else if (...
?
I found I think, the place could be https://github.com/JabRef/jabref/blob/31f137bcf22c15314f9bc951b694286b34ab2f2f/src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java#L178-L178. The above LOC also answers the following, doesn't it?
|
9799dc4
to
d6a0e59
Compare
Co-authored-by: Oliver Kopp <[email protected]>
Co-authored-by: Oliver Kopp <[email protected]>
Follow-up at JabRef#10578. Closing this one. The other PR is the same branch, but more committers can see it! |
Addresses Issue: #540
Command line now supports option "jumpToEntryKey" or "-j" folowed by one entrykey argument.
Upon start up, jabref will search the imported files for the entrykey and focus this library and select this entry.
However, I am experiencing issues when there are previously opened databases that are not opened through the command line. The last database within the previously opened databases seems to always be the library focused on start up as they seem to run on a different thread or something.
Currently the key is searched only in the imported files specified in the commandline [BIBTEX_FILE] fields. I also request some assistance as to how I can search the previously opened/edited databases as well for the entrykey.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)