Skip to content

feat: warn when output extension does not match --format#7

Merged
rasros merged 1 commit into
mainfrom
feat/warn-format-extension-mismatch
Jul 10, 2026
Merged

feat: warn when output extension does not match --format#7
rasros merged 1 commit into
mainfrom
feat/warn-format-extension-mismatch

Conversation

@rasros

@rasros rasros commented Jul 10, 2026

Copy link
Copy Markdown
Owner

What

If the -o path's extension doesn't match the chosen --format, vectrify silently wrote (say) DOT content into a .svg file. Now it logs a non-fatal warning and proceeds:

Output path 'out.svg' has extension '.svg' but --format graphviz produces '.dot' files; writing it anyway.

The check is case-insensitive and also fires when the path has no extension at all. It's a warning, not an error — the file is still written, since the user may have deliberately chosen a name.

How

A small pure helper format_extension_warning(output_path, fmt, expected_ext) -> str | None returns the message (or None when they match); main() logs it via the main logger right after selecting the format plugin. The plugin already exposes the canonical extension (.svg / .dot / .typ).

Tests

Parametrized match/mismatch cases in test_main.py, including case-insensitivity and the no-extension case. Full suite: 369 passed.

@rasros rasros merged commit ca2b107 into main Jul 10, 2026
1 check passed
@rasros rasros deleted the feat/warn-format-extension-mismatch branch July 10, 2026 19:07
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.

1 participant