Skip to content

v0.2.1 - feat(cli): flexible argument parsing, key normalization and legacy cleanup

Choose a tag to compare

@EliasMPJunior EliasMPJunior released this 07 Mar 00:58
· 148 commits to master since this release

Summary

This PR overhauls the CLI argument parsing logic to support flexible flag ordering and automatic key normalization, resolving issues where users were forced to provide arguments in a specific order. It also includes significant cleanup of legacy submodules and improves test coverage and output formatting.

Changes

1. CLI Argument Parsing (ontobdc/run/run.py)

  • Flexible Ordering: Implemented a pre-processing step for sys.argv that reconstructs the argument list. This ensures the Capability ID is always passed as the first positional argument to argparse, regardless of whether the user provided it via --id or where flags like --file-type are placed in the command.
  • Key Normalization: Added automatic normalization of CLI keys from kebab-case (e.g., --file-type) to snake_case (e.g., file_type) during the capability discovery phase. This aligns CLI usage with Python internal schemas.

2. Strategy Updates (ListFilesCliStrategy)

  • Updated argument mapping to use file_type (snake_case) instead of file-type, aligning with the updated Capability Schema.

3. Legacy Cleanup

  • Removed legacy submodules and directories: ontobdc-core, ontobdc-wip, core (submodule), wip (submodule).
  • Updated development scripts (branch.sh, commit.sh) to support the new directory structure (core and wip as regular directories).

4. Testing & Documentation

  • New Test: Added test_run_with_id_flag_after_args to verify that flags can be passed before the Capability ID.
  • Fixes: Fixed test_run_list_documents_by_type.py failures caused by strict ordering and key mismatch.
  • UX: Improved test_run_json.sh output with colored PASS/FAIL messages.
  • Documentation: Added SPEC008 - CLI Argument Parsing and Normalization detailing the new strategy.

Impact

  • Users can now run commands like ontobdc run --file-type yaml --id <ID> without errors.
  • Developers can define schemas using standard Python snake_case without worrying about CLI discovery mismatches.
  • The repository structure is cleaner and easier to maintain.

Verification

  • All tests passed, including new regression tests.
  • Verified manual execution of ontobdc run with various flag permutations.