v0.2.1 - feat(cli): flexible argument parsing, key normalization and legacy cleanup
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.argvthat reconstructs the argument list. This ensures the Capability ID is always passed as the first positional argument toargparse, regardless of whether the user provided it via--idor where flags like--file-typeare placed in the command. - Key Normalization: Added automatic normalization of CLI keys from
kebab-case(e.g.,--file-type) tosnake_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 offile-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 (coreandwipas regular directories).
4. Testing & Documentation
- New Test: Added
test_run_with_id_flag_after_argsto verify that flags can be passed before the Capability ID. - Fixes: Fixed
test_run_list_documents_by_type.pyfailures caused by strict ordering and key mismatch. - UX: Improved
test_run_json.shoutput with colored PASS/FAIL messages. - Documentation: Added
SPEC008 - CLI Argument Parsing and Normalizationdetailing 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_casewithout 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 runwith various flag permutations.