Handle LIB_GE_CREATE_obj and LIB_GE_CONF_define_IPL_conditions in poco_plugin #76

Merged
Christoph merged 2 commits from 74-lib-ge-create-obj-not-recognised-correctly into main 2026-10-14 20:10:56 +00:00
Owner

This change registers two new command handlers in server/src/plugins/poco_plugin.py and imports the builtin commands table used by one of them.

What changed

  • Added an import: from tclint.commands.builtin import commands as _builtin_commands.
  • Added _lib_ge_create_obj(args, parser) which performs argument validation and parses the third argument as a script.
  • Added _lib_ge_conf_define_ipl_conditions(args, parser) which validates an IPL-style if form and delegates the conditional parsing to the builtin if handler.
  • Registered both handlers in the plugin commands list: LIB_GE_CREATE_obj and LIB_GE_CONF_define_IPL_conditions.

Behavior details

  • LIB_GE_CREATE_obj handler:

    • Validates the number and basic shape of arguments. If the args fail a preliminary check it raises CommandArgError with a message expecting 3 args.
    • When a third argument is present it calls parser.parse_script on args[2] and returns the updated args.
    • Note: the implementation currently allows an argument vector of length 2 (the validation checks len(args) < 1 or len(args) > 3), but later unconditionally indexes args[2] when len(args) != 1. That indexing would raise IndexError for len(args) == 2. The code also special-cases a single BracedWord as an error. Please verify intended arity and whether 2-argument forms should be accepted or rejected.
  • LIB_GE_CONF_define_IPL_conditions handler:

    • Requires at least 5 arguments and that args[2].contents == "if"; otherwise raises CommandArgError with an explanatory expected format.
    • Delegates the remainder of the arguments to the builtin if command handler (_builtin_commands["if"]) and returns args[:3] concatenated with that result.

Why this matters

  • The plugin now recognizes and attempts to validate/parse two previously-unhandled command forms (LIB_GE_CREATE_obj and LIB_GE_CONF_define_IPL_conditions). That affects how scripts using these commands are processed by this plugin integration.

Testing

No test execution results were provided.

Recommended checks for reviewers/local testing:

  1. Unit tests / direct calls to the handlers:

    • LIB_GE_CREATE_obj:
      • Case with 3 args: verify parser.parse_script is called on the 3rd arg and that result is returned.
      • Case with 1 non-braced arg: verify it returns unchanged.
      • Case with 1 braced arg: verify it raises CommandArgError.
      • Case with 2 args: verify whether an error or IndexError occurs; confirm intended behavior and adjust implementation accordingly.
    • LIB_GE_CONF_define_IPL_conditions:
      • Valid IPL if-style sequences (>=5 args, args[2].contents == "if"): verify it delegates to the builtin if handler and returns a combined arg list.
      • Invalid sequences (missing if or too few args): verify CommandArgError is raised.
  2. Integration: run any existing tclint or plugin integration checks against sample scripts that use LIB_GE_CREATE_obj and LIB_GE_CONF_define_IPL_conditions.

Compatibility / Risks

  • The change is limited to adding handlers and an import; no other files were modified.
  • Potential runtime IndexError in _lib_ge_create_obj for 2-argument inputs should be reviewed and fixed if 2-argument forms are not intended to be accepted.

Reviewer notes

  • Confirm intended arity and behavior for LIB_GE_CREATE_obj and either tighten the validation to reject 2-argument calls or guard the indexing/behavior for 2-argument cases.
  • Verify the dependency on _builtin_commands is acceptable in this module and that the builtin if handler signature matches the delegated call pattern used here.

Closes #74

This change registers two new command handlers in `server/src/plugins/poco_plugin.py` and imports the builtin commands table used by one of them. What changed - Added an import: `from tclint.commands.builtin import commands as _builtin_commands`. - Added `_lib_ge_create_obj(args, parser)` which performs argument validation and parses the third argument as a script. - Added `_lib_ge_conf_define_ipl_conditions(args, parser)` which validates an IPL-style `if` form and delegates the conditional parsing to the builtin `if` handler. - Registered both handlers in the plugin `commands` list: `LIB_GE_CREATE_obj` and `LIB_GE_CONF_define_IPL_conditions`. Behavior details - `LIB_GE_CREATE_obj` handler: - Validates the number and basic shape of arguments. If the args fail a preliminary check it raises `CommandArgError` with a message expecting 3 args. - When a third argument is present it calls `parser.parse_script` on `args[2]` and returns the updated args. - Note: the implementation currently allows an argument vector of length 2 (the validation checks `len(args) < 1 or len(args) > 3`), but later unconditionally indexes `args[2]` when `len(args) != 1`. That indexing would raise `IndexError` for `len(args) == 2`. The code also special-cases a single `BracedWord` as an error. Please verify intended arity and whether 2-argument forms should be accepted or rejected. - `LIB_GE_CONF_define_IPL_conditions` handler: - Requires at least 5 arguments and that `args[2].contents == "if"`; otherwise raises `CommandArgError` with an explanatory expected format. - Delegates the remainder of the arguments to the builtin `if` command handler (`_builtin_commands["if"]`) and returns `args[:3]` concatenated with that result. Why this matters - The plugin now recognizes and attempts to validate/parse two previously-unhandled command forms (`LIB_GE_CREATE_obj` and `LIB_GE_CONF_define_IPL_conditions`). That affects how scripts using these commands are processed by this plugin integration. Testing No test execution results were provided. Recommended checks for reviewers/local testing: 1. Unit tests / direct calls to the handlers: - `LIB_GE_CREATE_obj`: - Case with 3 args: verify `parser.parse_script` is called on the 3rd arg and that result is returned. - Case with 1 non-braced arg: verify it returns unchanged. - Case with 1 braced arg: verify it raises `CommandArgError`. - Case with 2 args: verify whether an error or `IndexError` occurs; confirm intended behavior and adjust implementation accordingly. - `LIB_GE_CONF_define_IPL_conditions`: - Valid IPL `if`-style sequences (>=5 args, `args[2].contents == "if"`): verify it delegates to the builtin `if` handler and returns a combined arg list. - Invalid sequences (missing `if` or too few args): verify `CommandArgError` is raised. 2. Integration: run any existing tclint or plugin integration checks against sample scripts that use `LIB_GE_CREATE_obj` and `LIB_GE_CONF_define_IPL_conditions`. Compatibility / Risks - The change is limited to adding handlers and an import; no other files were modified. - Potential runtime `IndexError` in `_lib_ge_create_obj` for 2-argument inputs should be reviewed and fixed if 2-argument forms are not intended to be accepted. Reviewer notes - Confirm intended arity and behavior for `LIB_GE_CREATE_obj` and either tighten the validation to reject 2-argument calls or guard the indexing/behavior for 2-argument cases. - Verify the dependency on `_builtin_commands` is acceptable in this module and that the builtin `if` handler signature matches the delegated call pattern used here. Closes #74
feat(poco_plugin): add LIB_GE_CREATE_obj and IPL-conditions handlers
Some checks failed
Tests / python (pull_request) Has been cancelled
Tests / node (pull_request) Has been cancelled
0ecc8eb634
Register two new command handlers and import the builtin command table for reuse.

- Add LIB_GE_CREATE_obj handler: validates arg count (1–3), allows a single BracedWord to pass through, and parses the third argument with parser.parse_script when present; raises CommandArgError on wrong arity.
- Add LIB_GE_CONF_define_IPL_conditions handler: validates the pattern (<ctrl> <prop> if ...), delegates the remaining arguments to the builtin "if" implementation via _builtin_commands["if"], and returns the reconstructed arg list; raises CommandArgError on mismatch.

These handlers are appended to the plugin's commands list and enable parsing for the corresponding Poco-specific commands.

Fixes #74
Merge remote-tracking branch 'origin/main' into 74-lib-ge-create-obj-not-recognised-correctly
All checks were successful
Tests / python (pull_request) Successful in 50s
Tests / node (pull_request) Successful in 22s
593514d448
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Christoph/nx_post_support!76
No description provided.