code: def _get_cl_version(p, config):
      
      if not p.get("has_cl_version", True):
          return ""
      try:
          prog = config_utils.get_program(p["cmd"], config)
      except config_utils.CmdNotFound:
  
          localpy_cmd = os.path.join(os.path.dirname(sys.executable), p["cmd"])
          if os.path.exists(localpy_cmd):
              prog = localpy_cmd
          else:
              return ""
      args = p.get("args", "")
  
      cmd = "{prog} {args}"
      subp = subprocess.Popen(cmd.format(**locals()), stdout=subprocess.PIPE,
                              stderr=subprocess.STDOUT,
                              shell=True)
      with contextlib.closing(subp.stdout) as stdout:
          if p.get("stdout_flag"):
              v = _parse_from_stdoutflag(stdout, p["stdout_flag"])
          elif p.get("paren_flag"):
              v = _parse_from_parenflag(stdout, p["paren_flag"])
          else:
              lines = [l.strip() for l in str(stdout.read()).split("\n") if l.strip()]
              v = lines[-1]
      if v.endswith("."):
          v = v[:-1]
      return v
docs: Retrieve version of a single commandline program.