Closed ditsuke closed 1 year ago
I came across fx seeking this exact feature. I'm using AWS a lot currently, and when I manually run commands it would be useful to pipe into interactive fx to choose the property I want.
So I would just have to do $VALUABLE_INFO=$(aws <whichever> | fx)
to store for example an IP address (I never remember the path to the value...)
I think a fx -select or something will be ok.
So is it a feature you're still considering?
Yes, for sure. Don’t know when I gonna find time to implement it, unless someone decides to support this feature development)
Hi again, I have a prototype.
This works really simply: when the --select/-s flag is passed, the program outputs the value of the selected level/property (model.cursorPath()
) when exiting.
To make the program interactive when stdout is piped (aka not a tty), I use stderr.
It works, but as I think it might not be a good practice I have a second commit that use stderr only then the select flag is passed and output is not a tty.
Bubble Tea seams to work perfectly using stderr.
Otherwise, I'd need to dig into how programs like vipe
works to ask for user input while piping to other command.
You can try this feature with something like curl -s https://dummyjson.com/products/1 | go run . -s
or curl -s https://dummyjson.com/products/1 | go run . -s | cat
, and going into the document to select a property: it will output its value.
I'll open a pull request if you're interested :)
I propose extension to this feature: Three options:
.x[123]["some strange key"].key.a.b.c[0].d
) to be used with fx or jq.Now js has yank support.
@antonmedv
Now js has yank support.
It's good, but there are two drawbacks:
curl http://example.com/something.json|fx --select-value|jq -c 'to_entries[]'|sponge entries.jsonl
.
What
When exiting, we could use either an entry flag or a keyboard shortcut to output selected value to standard output.
Why
This would make
fx
useful as part of interactive pipelines.History
Previously implemented in the NodeJS version, but not yet in the rewritten-in-Go version. Previous request: #132.