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)
|
2018-12-17 06:33:26 +00:00
|
|
|
|
[![Snap Version](https://img.shields.io/badge/snap-10.0.0-blue.svg)](https://snapcraft.io/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.
|
|
|
|
|
|
2019-01-20 17:49:26 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a href="https://www.patreon.com/antonmedv"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160"></a>
|
|
|
|
|
<a href="https://www.wispay.io/t/ZQb" target="_blank"><img src="https://assets.wispay.io/wgt2_d_b.png" height="60"></a>
|
|
|
|
|
</p>
|
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 .
|
|
|
|
|
```
|
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
2019-01-30 03:16:22 +00:00
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
Open the repo in Gitpod, the free online dev environment for GitHub.
|
|
|
|
|
|
|
|
|
|
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/antonmedv/fx)
|
|
|
|
|
|
|
|
|
|
Or clone locally and run:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
# install dependencies
|
|
|
|
|
npm install
|
|
|
|
|
|
|
|
|
|
# run the build
|
|
|
|
|
npm run build
|
|
|
|
|
|
|
|
|
|
# try the built binary
|
|
|
|
|
./dist/fx-linux package.json
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
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)
|