code: def command_runner(shell_command, force_rerun_flag, outfile_checker, cwd=None, silent=False):
      
      program_and_args = shlex.split(shell_command)
  
      # Check if program is installed
      if not program_exists(program_and_args[0]):
          raise OSError('{}: program not installed'.format(program_and_args[0]))
  
      # Format outfile if working in cwd
      if cwd:
          # TODO: should this be done, or should user explicitly define whole outfile path?
          outfile_checker = op.join(cwd, op.basename(outfile_checker))
  
      # Check for force rerunning
      if force_rerun(flag=force_rerun_flag, outfile=outfile_checker):
          if silent:
              command = subprocess.Popen(program_and_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
              out, err = command.communicate()
              ret = command.returncode
          else:
              # Prints output
              for path in execute(cmd=program_and_args, cwd=cwd):
                  print(path, end="")
  
          # TODO: check return code and log properly
          log.debug('{}: Ran program, output to {}'.format(program_and_args[0], outfile_checker))
      else:
          log.debug('{}: Output already exists'.format(outfile_checker))
docs: Run a shell command with subprocess, with additional options to check if output file exists and printing stdout.
  
      Args:
          shell_command (str): Command as it would be formatted in the command-line (ie. "program -i test.in -o test.out").
          force_rerun_flag: If the program should be rerun even if the output file exists.
          outfile_checker (str): Name out the output file which may have been generated. This does not specify what the outfile
              will be, that should be done in the program's args or predetermined.
          cwd (str): Path to working directory where command will be executed.
          silent (bool): If program STDOUT should be printed to the current shell.
  
      Returns:
          bool: If the program ran successfully.