anchor.diff:          yield version_rev
   
   
  -    match json.loads(jsonArg):
  -        case {"orga": orga, "repo": repo}:
  -            token = os.environ.get("GITHUB_TOKEN", None)
  -            curl_cmd = list(curl_args(orga, repo, token))
  -            if debug:
  -                print(curl_cmd, file=sys.stderr)
  -            out = sub.check_output(curl_cmd)
  -            release = curl_result(orga, repo, out).get("tag_name", None)
  -
  -            # github sometimes returns an empty list even tough there are releases
  -            if not release:
  -                print(f"uh-oh, latest for {orga}/{repo} is not there, using HEAD", file=sys.stderr)
  -                release = "HEAD"
  -
  -            print(f"Fetching latest release ({release}) of {orga}/{repo} …", file=sys.stderr)
  -            sub.check_call(
  -                list(nix_prefetch_args(
  -                    url=f"https://github.com/{quote(orga)}/{quote(repo)}",
  -                    version_rev=release
  -                ))
  -            )
  +    def fetchRepo():
  +        """fetch the given repo and print its nix-prefetch output to stdout"""
  +        match jsonArg:
  +            case {"orga": orga, "repo": repo}:
  +                token = os.environ.get("GITHUB_TOKEN", None)
  +                curl_cmd = list(curl_args(orga, repo, token))
  +                if debug:
  +                    print(curl_cmd, file=sys.stderr)
  +                out = sub.check_output(curl_cmd)
  +                release = curl_result(orga, repo, out).get("tag_name", None)
  +
  +                # github sometimes returns an empty list even tough there are releases
  +                if not release:
  +                    print(f"uh-oh, latest for {orga}/{repo} is not there, using HEAD", file=sys.stderr)
  +                    release = "HEAD"
  +
  +                print(f"Fetching latest release ({release}) of {orga}/{repo} …", file=sys.stderr)
  +                sub.check_call(
  +                    list(nix_prefetch_args(
  +                        url=f"https://github.com/{quote(orga)}/{quote(repo)}",
  +                        version_rev=release
  +                    ))
  +                )
  +            case _:
  +                sys.exit("input json must have `orga` and `repo` keys")
  +
  +
  +    match mode:
  +        case "fetch-repo":
  +            fetchRepo()
           case _:
  -            sys.exit("input json must have `orga` and `repo` keys")
  +            sys.exit(f"mode {mode} unknown")
     '';
   
     # find the latest repos of a github organization
  
positive.code:     mkdir -p "$outputDir"
      ${foreachSh allGrammars
        ({name, orga, repo}: ''
          ${updateGrammar} '${lib.generators.toJSON {} {inherit orga repo;}}' \
            > $outputDir/${name}.json
        '')}
      ( echo "{ lib }:"
  
negative.code: 
      debug = True if os.environ.get("DEBUG", False) else False
  
      mode = sys.argv[1]
      jsonArg = json.loads(sys.argv[2])
  
  
      def curl_args(orga, repo, token):
  