import subprocess,json,sys
from pathlib import Path
f=json.loads(Path(sys.argv[1]).read_text())
repo=f['url'].removeprefix('https://gitlab.com/').removesuffix('.git')
for state in [[],['--all']]:
 for limit in [1,20,100]:
  args=['glab','mr','list','--repo',repo,'--source-branch','feature',*state,'--per-page',str(limit),'--output','json']
  raw=subprocess.check_output(args)
  print('$ glab mr list --source-branch feature '+' '.join(state)+f' --per-page {limit} --output json')
  print(f'Actual stdout: {len(raw)} bytes')
  for m in json.loads(raw):
   print({k:m.get(k) for k in ['iid','title','state','source_branch','source_project_id','target_project_id']},'descriptionCharacters=',len(m.get('description') or ''))
