Skip to content
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

feat: Add automatic detection of output format from filename #891

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mtsfoni
Copy link
Contributor

@mtsfoni mtsfoni commented Jul 1, 2024

Description

This PR adds a feature to automatically detect the output format based on the provided output filename's extension. If the -fn (or --filename) option is set but --json or the future --bom-format option is not set, the format is derived from the file extension. Explicit parameters --json or --bom-format will take precedence if set.

Changes

  • Added a new method SetOutputFormatFromFilename in Runner.cs to determine the format from the file extension.
  • Supported extensions: .xml, .json, .proto, .pb, .bin.
  • Integrated the format detection logic in the HandleCommandAsync method of Runner.cs.

Testing

  • Tested with various combinations of filename extensions and format options to ensure correct format detection and precedence of explicit parameters.

Related Issues

Please review the changes and provide feedback.

- Implemented logic to detect the output format from the output filename extension.
- If `-fn` is set but `--json` or `--bom-format` are not set, the format is determined based on the file extension.
- Supported extensions: .xml, .json, .proto, .pb, .bin.
- Explicit parameters `--json` or `--bom-format` take precedence if set.


Signed-off-by: Michael Tsfoni <[email protected]>
@mtsfoni mtsfoni requested a review from a team as a code owner July 1, 2024 10:53
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