def breakCommand(cmd, lineSize=150):
  """Formats commands with line breaks"""
  fmtCmd = ''
  begin = 0
  end = min(lineSize+1, len(cmd))
  while end - begin > lineSize:
    index = cmd.rfind(',', begin, end)
    if index == -1:
      fmtCmd += cmd[begin:end]
      begin = end
    else:
      fmtCmd += cmd[begin:index+1] + '\n'
      begin = index+1
    end = min(begin + lineSize+1, len(cmd))
  fmtCmd += cmd[begin:end]
  return fmtCmd