@@ -121,3 +121,72 @@ def step_pgcli_exits_with_error(context):
121121 # Clean up
122122 context .cmd_output = None
123123 context .exit_code = None
124+
125+
126+ @when ("we run pgcli with multiple -c options" )
127+ def step_run_pgcli_with_multiple_c (context ):
128+ """Run pgcli with multiple -c flags."""
129+ cmd = [
130+ "pgcli" ,
131+ "-h" , context .conf ["host" ],
132+ "-p" , str (context .conf ["port" ]),
133+ "-U" , context .conf ["user" ],
134+ "-d" , context .conf ["dbname" ],
135+ "-c" , "SELECT 'first' as result" ,
136+ "-c" , "SELECT 'second' as result" ,
137+ "-c" , "SELECT 'third' as result"
138+ ]
139+ try :
140+ context .cmd_output = subprocess .check_output (
141+ cmd ,
142+ cwd = context .package_root ,
143+ stderr = subprocess .STDOUT ,
144+ timeout = 10
145+ )
146+ context .exit_code = 0
147+ except subprocess .CalledProcessError as e :
148+ context .cmd_output = e .output
149+ context .exit_code = e .returncode
150+ except subprocess .TimeoutExpired as e :
151+ context .cmd_output = b"Command timed out"
152+ context .exit_code = - 1
153+
154+
155+ @when ("we run pgcli with mixed -c and --command" )
156+ def step_run_pgcli_with_mixed_options (context ):
157+ """Run pgcli with mixed -c and --command flags."""
158+ cmd = [
159+ "pgcli" ,
160+ "-h" , context .conf ["host" ],
161+ "-p" , str (context .conf ["port" ]),
162+ "-U" , context .conf ["user" ],
163+ "-d" , context .conf ["dbname" ],
164+ "-c" , "SELECT 'from_c' as source" ,
165+ "--command" , "SELECT 'from_command' as source"
166+ ]
167+ try :
168+ context .cmd_output = subprocess .check_output (
169+ cmd ,
170+ cwd = context .package_root ,
171+ stderr = subprocess .STDOUT ,
172+ timeout = 10
173+ )
174+ context .exit_code = 0
175+ except subprocess .CalledProcessError as e :
176+ context .cmd_output = e .output
177+ context .exit_code = e .returncode
178+ except subprocess .TimeoutExpired as e :
179+ context .cmd_output = b"Command timed out"
180+ context .exit_code = - 1
181+
182+
183+ @then ("we see all command outputs" )
184+ def step_see_all_command_outputs (context ):
185+ """Verify that all command outputs are present."""
186+ output = context .cmd_output .decode ('utf-8' )
187+ # Should contain output from all commands
188+ assert "first" in output or "from_c" in output , f"Expected 'first' or 'from_c' in output, but got: { output } "
189+ assert "second" in output or "from_command" in output , f"Expected 'second' or 'from_command' in output, but got: { output } "
190+ # For the 3-command test, also check for third
191+ if "third" in output or "result" in output :
192+ assert "third" in output , f"Expected 'third' in output for 3-command test, but got: { output } "
0 commit comments