Skip to content

Make default output filename suffix configurable (fixes #259)#429

Merged
kwart merged 4 commits into
intoolswetrust:masterfrom
AymenJeddou:configurable-output-suffix
Jul 5, 2026
Merged

Make default output filename suffix configurable (fixes #259)#429
kwart merged 4 commits into
intoolswetrust:masterfrom
AymenJeddou:configurable-output-suffix

Conversation

@AymenJeddou

Copy link
Copy Markdown
Contributor

Fixes #259
The default "_signed" suffix used to derive the output filename was hardcoded.
This adds an output.suffix key in advanced.properties (bundled default
_signed), exposed via AppConfig.defaultOutSuffix(), so non-English users
can localize it (e.g. _firmado).

Applied consistently across:

  • core BasicSignerOptions.getOutFileX() (used by the signing engines)
  • JavaFX GUI (MainWindowController)
  • Swing fallback GUI (SignPdfForm)
  • CLI default for -osuffix (the --help text now shows the configured value)

Docs updated: JSignPdf.adoc, advanced.default.properties, 3.1.0 release
notes. Added AppConfigTest coverage.

The existing -osuffix flag still overrides per-invocation. No Preferences
dialog control was added (file-editable only) — happy to add one if preferred.

…t#259)

Add an output.suffix advanced-config key (default "_signed") read via
AppConfig.defaultOutSuffix(), so the suffix appended to derive the output
filename can be localized. Replaces the hardcoded "_signed" in the core
getOutFileX(), the JavaFX and Swing GUIs, and the CLI -osuffix default.
Copilot AI review requested due to automatic review settings June 24, 2026 02:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new output.suffix advanced-config key (default _signed) and wires it through the shared signing model, both GUIs, and the CLI so the default output filename marker can be localized without requiring a per-invocation flag.

Changes:

  • Introduce AppConfig.defaultOutSuffix() backed by advanced.properties / bundled defaults, and use it when deriving default output filenames.
  • Update CLI --help text and documentation to describe the new output.suffix knob.
  • Add test coverage around the new accessor.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/docs/JSignPdf.adoc Documents output.suffix for GUI behavior and CLI option defaults.
jsignpdf/src/test/java/net/sf/jsignpdf/utils/AppConfigTest.java Adds assertions for the new defaultOutSuffix() accessor.
jsignpdf/src/main/java/net/sf/jsignpdf/SignPdfForm.java Uses AppConfig.defaultOutSuffix() for Swing GUI output filename suggestion.
jsignpdf/src/main/java/net/sf/jsignpdf/SignerOptionsFromCmdLine.java Uses configured suffix as the CLI default and injects it into help text formatting.
jsignpdf/src/main/java/net/sf/jsignpdf/fx/view/MainWindowController.java Uses AppConfig.defaultOutSuffix() for JavaFX output filename suggestion/default.
engines/api/src/main/resources/net/sf/jsignpdf/translations/messages.properties Updates hlp.outSuffix help text to include a formatted default suffix.
engines/api/src/main/resources/net/sf/jsignpdf/conf/advanced.default.properties Adds bundled default output.suffix=_signed with documentation.
engines/api/src/main/java/net/sf/jsignpdf/utils/AppConfig.java Adds defaultOutSuffix() accessor.
engines/api/src/main/java/net/sf/jsignpdf/BasicSignerOptions.java Uses configured suffix when computing getOutFileX() default output filename.
distribution/doc/release-notes/3.1.0.md Notes the new configurable default output suffix feature.

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

Comment on lines +29 to 38
@Test
public void defaultOutSuffixFallsBackToConstants() {
// DEFAULT_OUT_SUFFIX is the literal fallback when the bundled defaults resource is missing or empty.
String suffix = AppConfig.defaultOutSuffix();
assertEquals("Default value should match Constants",
net.sf.jsignpdf.Constants.DEFAULT_OUT_SUFFIX,
// If a developer has a real override, this assertion can be skipped — but on a clean checkout the
// bundled default matches the Constants literal.
suffix.isEmpty() ? net.sf.jsignpdf.Constants.DEFAULT_OUT_SUFFIX : suffix);
}
hlp.outPath=folder in which the signed documents will be stored. Default value is current folder.
hlp.outPrefix=prefix for signed file. Default value is empty prefix.
hlp.outSuffix=suffix for signed filename. Default value is "_signed". (e.g. sign process on file mydocument.pdf will create new file mydocument_signed.pdf)
hlp.outSuffix=suffix for signed filename. Default value is "{0}" (configurable with the output.suffix key in advanced.properties). E.g. sign process on file mydocument.pdf will create new file mydocument{0}.pdf
kwart and others added 3 commits June 28, 2026 21:36
- Use {0} placeholder in hlp.outSuffix across all locale files so non-English
  --help reflects the configured output.suffix; tidy the French string.
- Document the MessageFormat apostrophe-doubling requirement for translators.
- Re-resolve AppConfig.defaultOutSuffix() in loadCmdLine when -osuffix is
  absent, instead of trusting the construction-time field initializer.
- Replace the tautological AppConfigTest with one that exercises the
  output.suffix key and the bundled-default fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Now that master's advanced-override mechanism is merged in, lock in finding intoolswetrust#3:
loadCmdLine must re-resolve the configured output.suffix when -os is absent
(verified to fail without the else branch), and an explicit --out-suffix still wins.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kwart

kwart commented Jun 28, 2026

Copy link
Copy Markdown
Member

Thanks for this @AymenJeddou! I reviewed it and pushed a few follow-up commits to the branch:

  • Localized the -os help text — the {0} placeholder was only in the English messages.properties, so non-English --help still showed a hardcoded _signed (ironic given the feature targets exactly those users). Updated all locale files to use {0}, and tidied up the French string which had some pre-existing formatting issues.
  • Documented the MessageFormat gotcha — since hlp.outSuffix now goes through MessageFormat, added a translator note that literal apostrophes must be doubled (''), so future translations don't silently drop text.
  • Hardened the CLI defaultoutSuffix was captured by the field initializer at construction time, before advanced overrides are applied. After merging master (which has the -o key=value override support from Add advaned properties override support to CLI #435), -o output.suffix=… without an explicit -os was being ignored. loadCmdLine now re-resolves the default after overrides are applied. Added regression tests (verified they fail without the fix).
  • Replaced the tautological test with one that actually exercises the output.suffix key and the bundled-default fallback.

Merged latest master in too (clean, no conflicts). All tests green. Let me know if you'd like any of it adjusted!

@AymenJeddou

Copy link
Copy Markdown
Contributor Author

Thanks @kwart for the thorough review and for taking the time to push the fixes directly, that's helpful.

The localization gap makes sense, I missed that the {0} placeholder only landed in the English file, which defeats the point of the feature for exactly the users it targets. The translator note on apostrophe doubling is a good addition too.

The field-initializer ordering issue is a good catch. I hadn't accounted for the override mechanism from #435 applying after construction, so re-resolving in loadCmdLine is the correct place for it. The regression tests covering both the absent -os case and the explicit override winning look solid.

Everything reads well to me, nothing I'd want changed. Happy to have this go in as is.
I'd like to keep contributing. If there are open issues you'd consider a good fit, or areas where you'd welcome help, point me at them and I'll pick something up.

@kwart kwart merged commit 5977b59 into intoolswetrust:master Jul 5, 2026
1 check passed
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.

Could the default filename suffix be configurable somehow?

3 participants