Comment by ~jschmidt on ~xenrox/hut
I forgot this last one example which already works on your new branch and hopefully shows what I'm writing about at the end of my previous post:
[hut]$ ./hut --debug builds list 2>&1 1>/dev/null | sed 's/^.//' | jq -r '.query' | ./hut graphql --stdin builds | head -4 { "jobs": { "results": [ {
Comment by ~jschmidt on ~xenrox/hut
Would be great if you could take a look at it and share some feedback. I personally don't see much usefulness/appeal in it but maybe it is useful to you.
Here is my journey through that new feature (thanks):
[hut]$ ./hut --debug builds list {{"query":"query jobs ($cursor: Cursor) {\n\tjobs(cursor: $cursor) {\n\t\t... jobs\n\t}\n}\nfragment jobs on JobCursor {\n\tresults {\n\t\tid\n\t\tstatus\n\t\tnote\n\t\ttags\n\t\ttasks {\n\t\t\tname\n\t\t\tstatus\n\t\t}\n\t}\n\tcursor\n}\n","variables":{"cursor":null}} } #1239925 - copy-on-select-2/commits/implement-sourcehut-builds/.build.yml: ✔ SUCCESS ✔ make [...] :{{"query":"query jobs ($cursor: Cursor) {\n\tjobs(cursor: $cursor) {\n\t\t... jobs\n\t}\n}\nfragment jobs on JobCursor {\n\tresults {\n\t\tid\n\t\tstatus\n\t\tnote\n\t\ttags\n\t\ttasks {\n\t\t\tname\n\t\t\tstatus\n\t\t}\n\t}\n\tcursor\n}\n","variables":{"cursor":"gAAAAABmZ20mwWV870mNOhm-NXIvtTrofygLvocVJlFGBaNmM-Qroyk1qFoMeVcMXfn1yQL33gIRK5z_Zu1FCRqTgqgwYPrPJHjeBspW6jXTFLyX-09BUn7jpXFtwjdMAxJznQ-tCtbR"}} }
Uh. Right, debug output and pagerified output surely don't go well together. Plus the repeating requests are confusing. We could force single-paged output in debug mode, but sometimes one probably would actually like to debug paged output. So for the time being let's do:
[hut]$ ./hut --debug builds list 1>/dev/null {{"query":"query jobs ($cursor: Cursor) {\n\tjobs(cursor: $cursor) {\n\t\t... jobs\n\t}\n}\nfragment jobs on JobCursor {\n\tresults {\n\t\tid\n\t\tstatus\n\t\tnote\n\t\ttags\n\t\ttasks {\n\t\t\tname\n\t\t\tstatus\n\t\t}\n\t}\n\tcursor\n}\n","variables":{"cursor":null}} }
That's better, at least for the purpose of extracting the response body or the GraphQL query. Next try (one of the rare occasions where
2>&1 1>...
is actually TRT!):[hut]$ ./hut --debug builds list 2>&1 1>/dev/null | jq parse error: Objects must consist of key:value pairs at line 2, column 1
Hu? Oops, there is an extra pair of braces around the body. Where does that come from? Haven't seen or used that up-to-now, but then I'm a relative GraphQL newbie. Getting rid of the braces the quick-and-dirty way:
[hut]$ ./hut --debug builds list 2>&1 1>/dev/null | sed 's/^.//' | jq { "query": "query jobs ($cursor: Cursor) {\n\tjobs(cursor: $cursor) {\n\t\t... jobs\n\t}\n}\nfragment jobs on JobCursor {\n\tresults {\n\t\tid\n\t\tstatus\n\t\tnote\n\t\ttags\n\t\ttasks {\n\t\t\tname\n\t\t\tstatus\n\t\t}\n\t}\n\tcursor\n}\n", "variables": { "cursor": null } }
That's better and looks familiar to what I use when doing GraphQL with cURL. Now for the GraphQL itself:
[hut]$ ./hut --debug builds list 2>&1 1>/dev/null | sed 's/^.//' | jq -r '.query' | tr '\t' ' ' query jobs ($cursor: Cursor) { jobs(cursor: $cursor) { ... jobs } } fragment jobs on JobCursor { results { id status note tags tasks { name status } } cursor }
To summarize, the new debug option provides:
- debugging of the body
- the option to extract the request body in a way that could be used for cURL
- the option to extract the GraphQL in a way that could be used for
hut graphql
Only it's a bit involved to get to the latter two. One could add examples along the lines of mine above. Or one could extend the syntax of the debug option to more easily get there. The point is:
Besides I will probably work on structured output, I have an idea, but it will increase maintenance burden so no promises yet.
I think if there were an option available so that something along the lines of the following would work really easily:
hut --debug=graphql builds list > example.graphql # fiddle with example.graphql hut graphql --var=... --cursor=... < example.graphql
then you could perfectly well do without structured output, because then users would have an option to easily generate structured output at their will.
~mcepl, ~jschmidt: I've added a simple "debug" flag in a branch.
Would be great if you could take a look at it and share some feedback. I personally don't see much usefulness/appeal in it but maybe it is useful to you.
Besides I will probably work on structured output, I have an idea, but it will increase maintenance burden so no promises yet.
Comment by ~jschmidt on ~xenrox/hut
Would it be possible to get something like general --verbose or --debug option
Getting working examples from
hut
by means of some--debug
option really would be nice, so +1 from here.
Comment by ~jschmidt on ~xenrox/hut
Bah, plain text mails are also interpreted as Markdown, garbling the diffs. Didn't know that. Anyway, you'll get the gist.
Comment by ~jschmidt on ~xenrox/hut
~xenrox, thanks for going through this rather un-exciting exercise of updating all pagerify calls. I haven't checked all of these, but a plain
[hut]$ ./hut builds list jdfalksjdf no such user
behaves now as expected.
Two comments/questions:
@@ -117,16 +118,17 @@ func newGitListCommand() *cobra.Command { [...] } else if user == nil {
log.Fatal("no such user")
errors.New("no such user") }
"return" statement before "errors.New" missing?
@@ -393,11 +402,11 @@ func newGitACLListCommand() *cobra.Command { [...] } else if user == nil {
log.Fatal("no such user")
errors.New("no such user") } else if user.Repository == nil {
Same here?
Thanks again
Jens
I have refactored the pager a bit to fix this bug.
~jschmidt, ~bitfehler could you take a look if this branch works for you?
Comment by ~jschmidt on ~xenrox/hut
Yes, that seems to be it, thanks for the pointer. (Only that
hut meta show foobarbaz
actually does return some user information - probably some left-overs ...)I guess we can leave this todo open for improved visibility?
Comment by ~jschmidt on ~xenrox/hut
Same happens when provoking any kind of error:
[tmp]$ hut builds list foobarbaz no such user ^C
Ticket created by ~jschmidt on ~xenrox/hut
(Formerly: hut seems to hang and sets noecho when missing permissions)
I'm on current main with Debian GNU/Linux as underlying OS:
[hut]$ git rev-parse HEAD 6c85e1e3726a54e10783db84d72e0eafa1428090 [~]$ cat /etc/debian_version 12.5
When I start a hut command where I'm lacking permissions, hut seems to hang. When Ctrl-C'ing out of that, terminal echo is gone, so I have to reset the terminal:
[~]$ hut builds list jobs gqlclient: server failure: Access denied, missing PROFILE:RO grant ^^^^^ "hangs" here ^C [~]$ <<<<< no echo when typing here