2018-11-02 18:24:56 +00:00
|
|
|
|
<p align="center"><img src="https://user-images.githubusercontent.com/141232/35405308-4b41f446-0238-11e8-86c1-21f407cc8460.png" height="100" alt="fx"></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)
|
2018-01-25 17:30:05 +00:00
|
|
|
|
|
|
|
|
|
Command-line JSON processing tool
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
|
|
* Formatting and highlighting
|
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 🎨
|
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.
|
|
|
|
|
|
2018-12-02 15:13:31 +00:00
|
|
|
|
<a href="https://www.patreon.com/antonmedv">
|
|
|
|
|
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
|
|
|
|
</a>
|
|
|
|
|
|
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
|
|
|
|
|
$ curl ... | fx 'json => json.message' 'json => json.filter(x => x.startsWith("a"))'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
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 .
|
|
|
|
|
```
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
## Related
|
|
|
|
|
|
2018-11-14 10:44:56 +00:00
|
|
|
|
* [xx](https://github.com/antonmedv/xx) - fx-like JSON tool (*go*)
|
2018-11-14 10:44:37 +00:00
|
|
|
|
* [ymlx](https://github.com/matthewadams/ymlx) - fx-like YAML cli processor
|
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
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
2018-11-12 01:57:11 +00:00
|
|
|
|
[MIT](https://github.com/antonmedv/fx/blob/master/LICENSE)
|