Skip to content

FEAT: Select specific ODF format#275

Merged
carlwilson merged 2 commits intoalpha/1.20from
feat/format-selection
Dec 10, 2025
Merged

FEAT: Select specific ODF format#275
carlwilson merged 2 commits intoalpha/1.20from
feat/format-selection

Conversation

@carlwilson
Copy link
Member

  • added option -f/--format to restrict validation to a specific ODF format;
  • made profile and format options mutually exclusive options;
  • created custom convertor for format option to allow for use of MIME types, extensions and office format elements to select format;
  • wired CLI validation to use format specific validation when selected;
  • improved CLI help information; and
  • changed existing --format option to -o/--output as it feels more appropriate.

- added option `-f`/`--format` to restrict validation to a specific ODF format;
- made profile and format options mutually exclusive options;
- created custom convertor for format option to allow for use of MIME types, extensions and office format elements to select format;
- wired CLI validation to use format specific validation when selected;
- improved CLI help information; and
- changed existing `--format` option to `-o`/`--output` as it feels more appropriate.
@carlwilson carlwilson added the enhancement New feature or request label Dec 10, 2025
@carlwilson carlwilson self-assigned this Dec 10, 2025
@carlwilson carlwilson requested a review from Copilot December 10, 2025 17:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the ability to restrict ODF validation to a specific format through a new -f/--format command-line option.

Key changes:

  • Added -f/--format option to validate specific ODF formats (accepts extensions, MIME types, or document type names)
  • Made format and profile options mutually exclusive using picocli's @ArgGroup
  • Renamed the previous --format option to -o/--output for better clarity

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
odf-core/src/main/java/org/openpreservation/odf/validation/OdfValidatorImpl.java Removed unused imports as cleanup
odf-apps/src/main/java/org/openpreservation/odf/apps/FormatsConverter.java New custom type converter for picocli to parse format specifications from multiple input formats (extensions, MIME types, document types)
odf-apps/src/main/java/org/openpreservation/odf/apps/CliValidator.java Updated CLI structure with new format option, reorganized options into mutually exclusive groups, and improved help text formatting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 26 to 34
return dt.getFormats().iterator().next();
}
dt = DocumentType.getTypeByBodyElement(search);
if (dt != null) {
return dt.getFormats().iterator().next();
}
dt = DocumentType.getTypeByMimeString(search);
if (dt != null) {
return dt.getFormats().iterator().next();
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation detected. Lines 26, 30, and 34 use 2 spaces for indentation instead of 4 spaces like the rest of the file. This should be corrected to maintain consistent formatting.

Suggested change
return dt.getFormats().iterator().next();
}
dt = DocumentType.getTypeByBodyElement(search);
if (dt != null) {
return dt.getFormats().iterator().next();
}
dt = DocumentType.getTypeByMimeString(search);
if (dt != null) {
return dt.getFormats().iterator().next();
return dt.getFormats().iterator().next();
}
dt = DocumentType.getTypeByBodyElement(search);
if (dt != null) {
return dt.getFormats().iterator().next();
}
dt = DocumentType.getTypeByMimeString(search);
if (dt != null) {
return dt.getFormats().iterator().next();

Copilot uses AI. Check for mistakes.

@Option(names = { "-p", "--profile" }, description = "Validate using additional Spreadsheet preservation profile.")
private boolean profileFlag;
@Parameters(paramLabel = "FILE", arity = "1..*", description = "A list of Open Document Format spreadsheet files to validate.")
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The description still references "spreadsheet files" but the tool now supports validating all ODF document types (text, presentation, drawing, etc.). Consider updating to "Open Document Format files" or "ODF files" for accuracy.

Suggested change
@Parameters(paramLabel = "FILE", arity = "1..*", description = "A list of Open Document Format spreadsheet files to validate.")
@Parameters(paramLabel = "FILE", arity = "1..*", description = "A list of Open Document Format files to validate.")

Copilot uses AI. Check for mistakes.
- added comment to enum lookup try/catch ignore;
- fixed formatting issues;
- `FILE` parameter description so it refers to documents, not spreadsheets; and
- removed spreadsheet reference in POM names and descriptions.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

FormatOptions formatOptions = new CliValidator.FormatOptions();

static class FormatOptions {
@Option(names = { "-f", "--format" }, description = {"Validate a particular ODF format only", "This value can be an extension, a MIME type, or a document element name, e.g. spreadsheet."}, defaultValue = "UNKNOWN", converter = FormatsConverter.class)
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

Grammatical issue: "a document element name" should be "a document element name" - the example "e.g. spreadsheet" should use "e.g., spreadsheet" (with comma after "e.g.") for proper grammatical style.

Suggested change
@Option(names = { "-f", "--format" }, description = {"Validate a particular ODF format only", "This value can be an extension, a MIME type, or a document element name, e.g. spreadsheet."}, defaultValue = "UNKNOWN", converter = FormatsConverter.class)
@Option(names = { "-f", "--format" }, description = {"Validate a particular ODF format only", "This value can be an extension, a MIME type, or a document element name, e.g., spreadsheet."}, defaultValue = "UNKNOWN", converter = FormatsConverter.class)

Copilot uses AI. Check for mistakes.
@carlwilson carlwilson merged commit b236191 into alpha/1.20 Dec 10, 2025
11 checks passed
@carlwilson carlwilson deleted the feat/format-selection branch December 10, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant