Created
June 21, 2025 00:17
-
-
Save dbuenzli/b59c348b122303d9bd277629b597826b to your computer and use it in GitHub Desktop.
open gh issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ocaml | |
(*--------------------------------------------------------------------------- | |
Copyright (c) 2025 Daniel C. Bünzli. All rights reserved. | |
SPDX-License-Identifier: ISC | |
---------------------------------------------------------------------------*) | |
#use "topfind" | |
#require "b0.std" | |
#require "b0.kit" | |
open B0_std | |
open Result.Syntax | |
let open_issue ~user ~repo_url ~title ~body = | |
let* httpc = B0_http.Http_client.make () in | |
let* auth = B0_github.Auth.make ~user () in | |
let* repo = B0_github.Repo.of_url repo_url in | |
let* num, url = B0_github.Issue.open' httpc auth repo ~title ~body () in | |
let* path = match B0_url.path url with | |
| None -> Fmt.error "No path in returned url %s" url | |
| Some path -> Ok path | |
in | |
let* json = B0_github.req_json_v3 httpc auth ~path `GET `Empty in | |
let* html_url = B0_json.Jsonq.(query (mem "html_url" string)) json in | |
Log.stdout (fun m -> m "@[%s@]" html_url); | |
Ok () | |
let user = None (* See B0_github.Auth.make to see how one is looked up. *) | |
let title = "TODO" | |
let body = | |
{|TODO|} | |
let main () = | |
Log.if_error ~use:1 @@ | |
let* () = open_issue ~user ~repo_url:Sys.argv.(1) ~title ~body in | |
Ok 0 | |
let () = if !Sys.interactive then () else exit (main ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment