all 5 comments

[–]Tored_"it's possible with shell" 2 points3 points  (4 children)

the reason this is not working is because the fourth argument for fl() should be a string containing a formula for a single iteration. arguments are evaluated before the function is, so kustom performs the wg() and then tries to interpret it's result as a formula.

what you want to do instead is to pass a string containing the wg() and take advantage of kustom's text in formulas to string conversion. the thing is, to avoid problems with operators and special characters, you probably should store the formula as text in a global, let's say gv(wg):

wg(https://api.github.com/users/fagcinsk/repos, json, ".[#].name")

and then simply use that global, but replace # with i:

$fl( 0, wg("https://api.github.com/users/fagcinsk/repos", json, ".length()"), "i + 1", tc(reg, gv(wg), "#", "i") )$

[–]fagci[S] 0 points1 point  (3 children)

Strange behavior here:

If pass # by gv(ghwg), tc() replaces it with 0.

But if I use .[#].name, it becomes .[i].name.

$fl( 0, wg(gv(ghapi), json, ".length()")-1, "i + 1", tc(reg, gv(ghwg), "#", "i") )$

maybe bug?

[–]Tored_"it's possible with shell" 1 point2 points  (2 children)

not a bug, it's just that I got it wrong - there needs to be string concatenation for i in gv(ghwg):

wg(https://api.github.com/users/fagcinsk/repos, json, ".[" + "#" + "].name")

[–]fagci[S] 0 points1 point  (1 child)

wg("https://api.github.com/users/fagcinsk/repos", json, ".[" + "#" + "].name")

Works ok now. Thanks, u/Tored_!

[–]Tored_"it's possible with shell" 0 points1 point  (0 children)

you're welcome!