def run_command_with_live_output(command: list[str]) -> None: """ Courtesy of ChatGPT: Runs a command and prints its output line by line as it executes. Args: command (List[str]): The command and its arguments to be executed. Returns: None """ process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # Print the output line by line while True: output = process.stdout.readline() if output == '' and process.poll() is not None: break if output: print(output.strip()) # Print the error output, if any err_output = process.stderr.read() if err_output: print(err_output)