2018-12-17 06:33:26 +00:00
|
|
|
|
<p align="center"><img src="https://medv.io/assets/fx-logo.png" height="100" alt="fx logo"></p>
|
2018-12-03 05:08:40 +00:00
|
|
|
|
<p align="center"><img src="https://medv.io/assets/fx.gif" width="562" alt="fx example"></p>
|
2018-11-02 18:24:56 +00:00
|
|
|
|
|
|
|
|
|
_* Function eXecution_
|
2018-01-25 18:31:26 +00:00
|
|
|
|
|
2018-11-13 05:05:13 +00:00
|
|
|
|
[![Build Status](https://travis-ci.org/antonmedv/fx.svg?branch=master)](https://travis-ci.org/antonmedv/fx)
|
2018-12-11 12:27:22 +00:00
|
|
|
|
[![Npm Version](https://img.shields.io/npm/v/fx.svg)](https://www.npmjs.com/package/fx)
|
|
|
|
|
[![Brew Version](https://img.shields.io/homebrew/v/fx.svg)](https://formulae.brew.sh/formula/fx)
|
2019-03-01 01:38:51 +00:00
|
|
|
|
![Nyancat Approved](https://img.shields.io/badge/nyancat-approved-ff69b4.svg)
|
2018-01-25 17:30:05 +00:00
|
|
|
|
|
|
|
|
|
Command-line JSON processing tool
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
2019-02-24 18:41:01 +00:00
|
|
|
|
* Easy to use
|
2018-01-30 13:20:11 +00:00
|
|
|
|
* Standalone binary
|
2018-11-02 18:24:56 +00:00
|
|
|
|
* Interactive mode 🎉
|
2018-12-02 16:02:31 +00:00
|
|
|
|
* Themes support 🎨
|
2019-02-24 18:41:01 +00:00
|
|
|
|
* Streaming support 🌊
|
2019-02-28 16:20:35 +00:00
|
|
|
|
* Bash completion
|
2018-01-25 17:30:05 +00:00
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ npm install -g fx
|
|
|
|
|
```
|
2018-11-16 11:07:22 +00:00
|
|
|
|
Or via Homebrew
|
|
|
|
|
```
|
|
|
|
|
$ brew install fx
|
|
|
|
|
```
|
2018-01-25 17:30:05 +00:00
|
|
|
|
|
2018-01-26 23:51:21 +00:00
|
|
|
|
Or download standalone binary from [releases](https://github.com/antonmedv/fx/releases) page.
|
|
|
|
|
|
2019-02-28 16:20:35 +00:00
|
|
|
|
Did you like **fx**? [Buy me a beer 🍺](https://paypal.me/antonmedv) or [send come ₿](https://www.wispay.io/t/ZQb)
|
2018-12-02 15:13:31 +00:00
|
|
|
|
|
2018-01-25 17:30:05 +00:00
|
|
|
|
## Usage
|
|
|
|
|
|
2018-12-03 05:08:40 +00:00
|
|
|
|
Start [interactive mode](https://github.com/antonmedv/fx/blob/master/docs.md#interactive-mode) without passing any arguments.
|
2018-01-25 17:30:05 +00:00
|
|
|
|
```
|
2018-11-02 18:24:56 +00:00
|
|
|
|
$ curl ... | fx
|
2018-01-25 17:30:05 +00:00
|
|
|
|
```
|
|
|
|
|
|
2018-12-02 15:13:31 +00:00
|
|
|
|
Or by passing filename as first argument.
|
2018-01-26 16:06:25 +00:00
|
|
|
|
```
|
2018-12-02 15:13:31 +00:00
|
|
|
|
$ fx data.json
|
2018-03-19 17:15:05 +00:00
|
|
|
|
```
|
2018-11-09 16:58:15 +00:00
|
|
|
|
|
2018-12-02 15:17:35 +00:00
|
|
|
|
Pipe into `fx` any JSON and anonymous function for reducing it.
|
|
|
|
|
```bash
|
|
|
|
|
$ curl ... | fx 'json => json.message'
|
|
|
|
|
```
|
|
|
|
|
|
2018-12-02 15:21:37 +00:00
|
|
|
|
Or same as above but short.
|
2018-12-02 15:17:35 +00:00
|
|
|
|
```bash
|
|
|
|
|
$ curl ... | fx this.message
|
|
|
|
|
$ curl ... | fx .message
|
|
|
|
|
```
|
|
|
|
|
|
2018-12-02 15:21:37 +00:00
|
|
|
|
Pass any numbers of arguments as code.
|
2018-12-02 15:25:56 +00:00
|
|
|
|
```bash
|
2019-01-30 03:16:22 +00:00
|
|
|
|
$ curl ... | fx 'json => json.message' 'json => json.filter(x => x.startsWith("a"))'
|
2018-12-02 15:25:56 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Access all lodash (or ramda, etc) methods by using [.fxrc](https://github.com/antonmedv/fx/blob/master/docs.md#using-fxrc) file.
|
|
|
|
|
```bash
|
2018-12-13 05:40:21 +00:00
|
|
|
|
$ curl ... | fx '_.groupBy("commit.committer.name")' '_.mapValues(_.size)'
|
2018-12-02 15:21:37 +00:00
|
|
|
|
```
|
2018-12-02 15:25:56 +00:00
|
|
|
|
|
|
|
|
|
Update JSON using spread operator.
|
|
|
|
|
```bash
|
|
|
|
|
$ echo '{"count": 0}' | fx '{...this, count: 1}'
|
|
|
|
|
{
|
|
|
|
|
"count": 1
|
|
|
|
|
}
|
2018-12-02 15:21:37 +00:00
|
|
|
|
```
|
|
|
|
|
|
2018-12-02 15:27:46 +00:00
|
|
|
|
Pretty print JSON with dot.
|
|
|
|
|
```bash
|
|
|
|
|
$ curl ... | fx .
|
|
|
|
|
```
|
|
|
|
|
|
2019-02-28 16:20:35 +00:00
|
|
|
|
Stream JSON into fx.
|
|
|
|
|
```bash
|
|
|
|
|
$ kubectl logs ... -f | fx .message
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Apply fx to a few JSON files.
|
|
|
|
|
```bash
|
|
|
|
|
$ cat *.json | fx .length
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
|
|
```
|
|
|
|
|
|
2019-02-24 08:01:52 +00:00
|
|
|
|
And try this:
|
|
|
|
|
```bash
|
|
|
|
|
$ fx --life
|
|
|
|
|
```
|
|
|
|
|
|
2018-12-02 15:13:31 +00:00
|
|
|
|
## Documentation
|
2018-11-09 16:58:15 +00:00
|
|
|
|
|
2018-12-02 15:13:31 +00:00
|
|
|
|
See full [documentation](https://github.com/antonmedv/fx/blob/master/docs.md).
|
2018-01-25 17:30:05 +00:00
|
|
|
|
|
2018-12-19 10:01:50 +00:00
|
|
|
|
## Links
|
|
|
|
|
|
|
|
|
|
* [Discover how to use fx effectively](https://medium.com/@antonmedv/discover-how-to-use-fx-effectively-668845d2a4ea)
|
|
|
|
|
|
2018-01-25 17:30:05 +00:00
|
|
|
|
## Related
|
|
|
|
|
|
2019-02-24 18:42:01 +00:00
|
|
|
|
* [xx](https://github.com/antonmedv/xx) – fx-like JSON tool (*go*)
|
2019-02-24 06:57:23 +00:00
|
|
|
|
* [eat](https://github.com/antonmedv/eat) – converts anything into JSON
|
2019-02-24 18:42:01 +00:00
|
|
|
|
* [ymlx](https://github.com/matthewadams/ymlx) – fx-like YAML cli processor
|
2019-02-28 16:21:19 +00:00
|
|
|
|
* [fx-completion](https://github.com/antonmedv/fx-completion) – bash completion for fx
|
2018-12-02 16:09:50 +00:00
|
|
|
|
* [fx-theme-monokai](https://github.com/antonmedv/fx-theme-monokai) – monokai theme
|
2018-12-03 16:05:21 +00:00
|
|
|
|
* [fx-theme-night](https://github.com/antonmedv/fx-theme-night) – night theme
|
2018-01-25 17:30:05 +00:00
|
|
|
|
|
2019-01-30 03:16:22 +00:00
|
|
|
|
|
2018-01-25 17:30:05 +00:00
|
|
|
|
## License
|
|
|
|
|
|
2019-01-30 03:16:22 +00:00
|
|
|
|
[MIT](https://github.com/antonmedv/fx/blob/master/LICENSE)
|