Skip to content

Closes #13275 : export footer only for commands that support --output #13277

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

070jhz
Copy link
Contributor

@070jhz 070jhz commented Jun 8, 2025

Closes #13275
the --output option is more indicative of export behavior than --output-format while checking among the option names.

Steps to test

Commands that export

./gradlew :jabkit:run --args="convert --help"
./gradlew :jabkit:run --args="generate-bib-from-aux --help"
./gradlew :jabkit:run --args="generate-citation-keys --help"
./gradlew :jabkit:run --args="pseudonymize --help"
./gradlew :jabkit:run --args="search --help"

Commands that don't

./gradlew :jabkit:run --args="check-consistency --help"
./gradlew :jabkit:run --args="pdf --help"
./gradlew :jabkit:run --args="preferences --help"

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked 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 to the documentation repository.

@koppor
Copy link
Member

koppor commented Jun 8, 2025

Commands that export

Err. No.

@070jhz
Copy link
Contributor Author

070jhz commented Jun 8, 2025

Am I misunderstanding something ?

@koppor
Copy link
Member

koppor commented Jun 8, 2025

Am I misunderstanding something ?

Yes.

Proposal: Write documentation for each CLI command to our user-documentation repository.

Moreover, think of tests. As simple as expected --help output. Check for the strip after the "header".

If you are not able to do the former, the latter is required. Otherwise, we cannot check without running all the commands for ourselves and thinking if this is right what you claim

@070jhz 070jhz marked this pull request as draft June 8, 2025 11:16
@070jhz
Copy link
Contributor Author

070jhz commented Jun 8, 2025

Moreover, think of tests. As simple as expected --help output. Check for the strip after the "header".

Fair enough, I'm not familiar with JUnit or the project's testing conventions though so I don't know if I approached it correctly in my last commit

@calixtus
Copy link
Member

calixtus commented Jun 9, 2025

Moreover, think of tests. As simple as expected --help output. Check for the strip after the "header".

Be aware: We don't need to test if PicoCli works. I am sure that PicoCli has an extensive test suite.

Test logic, not strings.

@koppor
Copy link
Member

koppor commented Jun 10, 2025

Test logic, not strings.

In this case, some "grep"ing would make sense. Checking if the help output does not contain the export formats. (We do this in fetcher tests when we remove abstracts)

Alterantively, full help output string checking. If we update the CLI, all tests need to be updated. We do this at fetcher tests (because we compare the complete result)

I'm not sure, which way to go. Maybe "grep"ping is fine.

when(preferences.getExportPreferences()).thenReturn(exportPreferences);
when(preferences.getImportFormatPreferences()).thenReturn(importFormatPreferences);

when(exportPreferences.getCustomExporters()).thenReturn(FXCollections.emptyObservableList());
Copy link

Choose a reason for hiding this comment

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

In JabRef, to create an empty list we use List.of() instead of FXCollections.emptyObservableList() to maintain consistency with the rest of the codebase.

when(preferences.getImportFormatPreferences()).thenReturn(importFormatPreferences);

when(exportPreferences.getCustomExporters()).thenReturn(FXCollections.emptyObservableList());
when(importerPreferences.getCustomImporters()).thenReturn(FXCollections.emptyObservableSet());
Copy link

Choose a reason for hiding this comment

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

In JabRef, to create an empty set we use Set.of() instead of FXCollections.emptyObservableSet() to maintain consistency with the rest of the codebase.


if ("fetch".equals(name)) {
// special case: expect footer NOT present
assertEquals(false, containsExportFormats,
Copy link

Choose a reason for hiding this comment

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

Assert the contents of objects (assertEquals), not checking for some Boolean conditions (assertTrue/assertFalse) to improve readability and maintainability.

assertEquals(false, containsExportFormats,
"Did not expect 'Available export formats' in footer for special case: " + name);
} else if (hasOutputOption) {
assertEquals(true, containsExportFormats,
Copy link

Choose a reason for hiding this comment

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

Assert the contents of objects (assertEquals), not checking for some Boolean conditions (assertTrue/assertFalse) to improve readability and maintainability.

@jabref-machine
Copy link
Collaborator

Your code currently does not meet JabRef's code guidelines. We use OpenRewrite to ensure "modern" Java coding practices. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Tests / OpenRewrite (pull_request)" and click on it.

The issues found can be automatically fixed. Please execute the gradle task rewriteRun from the rewrite group of the Gradle Tool window in IntelliJ, then check the results, commit, and push.

@070jhz
Copy link
Contributor Author

070jhz commented Jun 10, 2025

Thank you both for your insights. It now accesses the raw data model in picocli where applyUsageFooters places the footer string. It's still grepping but no longer calls for picocli to format the help text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not output "export formats" for consistency check help
4 participants