Skip to content

Handle boolean flag parameters correctly in CommandExecutor.run_topp()#350

Open
t0mdavid-m wants to merge 1 commit intomainfrom
claude/add-boolean-flag-support-ZFNp4
Open

Handle boolean flag parameters correctly in CommandExecutor.run_topp()#350
t0mdavid-m wants to merge 1 commit intomainfrom
claude/add-boolean-flag-support-ZFNp4

Conversation

@t0mdavid-m
Copy link
Member

Summary

This PR adds proper handling for boolean flag parameters in the CommandExecutor.run_topp() method. Boolean parameters are now correctly converted to TOPP command-line flags: True values emit only the flag (no value), while False values omit the flag entirely. This distinguishes them from string-based boolean parameters ("true"/"false") which continue to emit explicit values.

Changes

  • CommandExecutor.py: Added boolean parameter detection and handling logic

    • True boolean values now emit only the flag name (e.g., -enable_feature)
    • False boolean values are skipped entirely (flag not emitted)
    • String values "true"/"false" continue to work as before (emitted with explicit values)
    • Other parameter types (int, float, str, empty, multiline) remain unchanged
  • test_boolean_flag_params.py: Added comprehensive test suite

    • Tests verify correct flag-only emission for bool True
    • Tests verify complete omission for bool False
    • Tests confirm string "true"/"false" still emit explicit values
    • Tests validate all other parameter types work as expected
    • Tests ensure standard flags (-threads, -ini, -in) are still present

Implementation Details

The implementation uses a simple isinstance(v, bool) check before the existing parameter processing logic. When a boolean is detected:

  • If True: append the flag and continue to skip the normal value-appending logic
  • If False: continue to skip the flag entirely
  • Non-boolean values fall through to existing logic unchanged

This approach maintains backward compatibility while adding proper support for registerFlag_ style parameters in TOPP tools.

https://claude.ai/code/session_016pdqzsAKEB6UDBcGM82T6F

TOPP tools have two boolean parameter styles: flag-style (registerFlag_)
where presence means enabled, and string-style (registerStringOption_
with valid_strings=["true","false"]) where explicit values are required.

Add isinstance(v, bool) check in the params[tool] loop so that:
- Python bool True emits only the flag (e.g., -flag)
- Python bool False omits the flag entirely
- String "true"/"false" continues to emit -param true / -param false

This fixes tools like FLASHDeconv and FLASHTnT that expect POSIX-style
boolean flags.

https://claude.ai/code/session_016pdqzsAKEB6UDBcGM82T6F
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.

2 participants