allow for JSON output instead of ansi-escaped output
From Announcing Cloud Foundry cf v6:
Written to be scripted
Part of being able to "script" gcf means being able to get the output of a command in a form easily digested by a script. Eg, JSON. Currently, I don't see how to do that.
It's nice that the output is going to stdout now - I think some of it used to go to tty and couldn't be captured at all. But redirecting gcf apps, for instance, shows interesting bits interspersed with ansi sequences, fixed white-space for columnizing, etc. It could be scraped, but who wants to do that?
@tedsuo has been talking about this for a few weeks now. It's definitely on our radar.
We will definitely be adding machine-readable output, triggered by an env var and by sniffing for tty. However, it will probably not be JSON format, since JSON has no common standard for streaming and doesn't play well with pipes/other command line tools.
streaming structured data - hmmm ...
A bit of a stretch, but you may want to consider text/event-stream, ala server-sent events
I'm also interested in this feature. The old Ruby cf had the --script parameter but the Go cf has nothing like that yet, which is a step backwards.
Since bringing this up, I think I've found that cf curl will purty much do what I want to do. Kinda wonky, but I can write scripts to "do stuff" against cf by exec()'ing cf curl. Overkill, presumably, when I'm doing a bunch of these, but ... works.
For some reason, I didn't think cf curl was in cfv6; I was wrong.
@pmuellr can you think of any way that the output of cf curl could be improved? In its current form it really feels like its output was designed for humans, but I'd really like for it (and other commands) to have output that feels more natural for a script to parse.
We've been thinking about this for a few months now, and I don't feel any closer to having a standard for how we should stream the output of cf so that it's easier for scripts to consume.
@tjarratt:
My use case for using cf curl is that I actually want a cf api for my flavorite programming language (doesn't matter which). But, that's a pain, and I have to deal with the auth story is more pain.
cf curl to the rescue; instead of dealing with http and auth, I just have to exec(). Much easier.
I will admit I've only prototyped a little tool using exec(cf curl) as my "API" once. There are prolly some interesting pointy edges around error responses, etc. Haven't played enough to find them though. Seemed easy enough that I'll prolly do it again, when the need arises.
Downside, if my app is issuing many, many cf calls, via cf curl, well that's just exec() overhead in my opinion. I think it would be nice to have some kind of 'server mode' , where I could exec() cf curl --server and it stay up until stdin closed. It would read "packets" from stdin, and write "packets" back out to stdout. That way I can leave it up issue commands all day long.
Haven't thought too much about how that would work. Perhaps using text/event-stream format for both stdin/stdout?
@pmuellr @tjarratt Is this still an issue worth pursuing? I don't see that a story ever hit the CLI backlog..... Thx
Judging from the lack of interest, I'd say no.
On Mon, Sep 15, 2014 at 3:29 PM, greg oehmen [email protected] wrote:
@pmuellr https://github.com/pmuellr @tjarratt https://github.com/tjarratt Is this still an issue worth pursuing? I don't see that a story ever hit the CLI backlog..... Thx
— Reply to this email directly or view it on GitHub https://github.com/cloudfoundry/cli/issues/25#issuecomment-55644961.
Patrick Mueller http://muellerware.org