Skip to content

fix: reorder argument validation flow (fixes #18) - #19

Open
yunaremaia wants to merge 1 commit into
mavonx:mainfrom
yunaremaia:fix/reorder-validation-flow
Open

fix: reorder argument validation flow (fixes #18)#19
yunaremaia wants to merge 1 commit into
mavonx:mainfrom
yunaremaia:fix/reorder-validation-flow

Conversation

@yunaremaia

Copy link
Copy Markdown

Summary

Reorders the argument validation flow in src/main.cpp to produce accurate, non-misleading error messages.

Previously the extension check ran before the existence check, so a non-existent file such as non_existent.csv could be rejected with file must be a .csv file. This PR fixes the order as requested in #18.

Changes

Reordered validation in src/main.cpp to:

  1. hydra::exists(csv_path)Error: file does not exist: <path>
  2. hydra::is_directory(csv_path)Error: path is a directory: <path>
  3. hydra::has_csv_extension(csv_path)Error: file must be a .csv file
  4. hydra::is_readable_file(csv_path)Could not open file: <path>

No other files changed. Messages and helpers remain unchanged, only the guard order.

Validation

Built locally with CMake + Make (FTXUI 7.0.3, GCC 16.2.1) and tested manually:

Input Expected Actual
hydra non_existent.csv Error: file does not exist: non_existent.csv
hydra my_folder.csv (directory) Error: path is a directory: my_folder.csv
hydra data.txt (existing non-csv) Error: file must be a .csv file
hydra valid.csv (valid file) renders TUI
hydra non_existent.txt file does not exist (not misleading csv error)

Existing test suite (hydra_tests) still passes.

Fixes #18

Reorder validation checks in src/main.cpp to avoid misleading errors:

1. hydra::exists(csv_path) -> Error: file does not exist
2. hydra::is_directory(csv_path) -> Error: path is a directory
3. hydra::has_csv_extension(csv_path) -> Error: file must be a .csv file
4. hydra::is_readable_file(csv_path) -> Could not open file

Previously the extension was checked before existence, which produced
'file must be a .csv file' even for non-existent paths.
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.

Reorder argument validation flow

1 participant