diff --git a/pydra/compose/shell/builder.py b/pydra/compose/shell/builder.py index 82ffeb3ca..a46d753a8 100644 --- a/pydra/compose/shell/builder.py +++ b/pydra/compose/shell/builder.py @@ -512,6 +512,9 @@ def from_type_str(type_str) -> type: f"Found unknown token {token!r} in command line template: {template}" ) + if option: + raise ValueError(f"Found an option without a field: {option!r}") + remaining_pos = remaining_positions(arguments, len(arguments) + 1, 1) for argument in arguments: diff --git a/pydra/compose/shell/tests/test_shell_fields.py b/pydra/compose/shell/tests/test_shell_fields.py index 79459e0f7..141310566 100644 --- a/pydra/compose/shell/tests/test_shell_fields.py +++ b/pydra/compose/shell/tests/test_shell_fields.py @@ -984,6 +984,13 @@ def test_shell_missing_executable_dynamic(): ) +def test_shell_trailing_option_fail(): + + with pytest.raises(ValueError, match="Found an option without a field"): + + shell.define("ls --unparameterized-option ") + + def test_shell_help1(): Shelly = shell.define(