fx/README.md

109 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

2019-03-08 07:11:21 +00:00
<p align="center"><a href="http://fx.wtf"><img src="https://medv.io/assets/fx-logo.png" height="100" alt="fx logo"></a></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
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 🎉
2019-02-24 18:41:01 +00:00
* Streaming support 🌊
2018-01-25 17:30:05 +00:00
## Install
2019-12-07 10:09:58 +00:00
```bash
2019-12-15 02:12:49 +00:00
npm install -g fx
2018-01-25 17:30:05 +00:00
```
2018-11-16 11:07:22 +00:00
Or via Homebrew
2019-12-07 10:09:58 +00:00
```bash
2019-12-15 02:12:49 +00:00
brew install fx
```
Or download standalone binary from [releases](https://github.com/antonmedv/fx/releases)
```bash
2020-09-03 21:54:32 +00:00
bash <( curl https://fx.wtf )
2018-11-16 11:07:22 +00:00
```
2018-01-26 23:51:21 +00:00
2018-01-25 17:30:05 +00:00
## Usage
2019-03-07 16:47:04 +00:00
Start [interactive mode](https://github.com/antonmedv/fx/blob/master/DOCS.md#interactive-mode) without passing any arguments.
2019-12-07 10:09:58 +00:00
```bash
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-12-02 15:17:35 +00:00
```bash
2019-12-07 10:09:58 +00:00
$ fx data.json
2018-12-02 15:17:35 +00:00
```
2019-12-07 10:09:58 +00:00
Pass a few JSON files.
2018-12-02 15:17:35 +00:00
```bash
2019-12-07 10:09:58 +00:00
cat foo.json bar.json baz.json | fx .message
2018-12-02 15:17:35 +00:00
```
2019-12-07 10:09:58 +00:00
Use full power of JavaScript.
2018-12-02 15:25:56 +00:00
```bash
2019-12-07 10:09:58 +00:00
$ curl ... | fx '.filter(x => x.startsWith("a"))'
2018-12-02 15:25:56 +00:00
```
2019-03-07 16:47:04 +00:00
Access all lodash (or ramda, etc) methods by using [.fxrc](https://github.com/antonmedv/fx/blob/master/DOCS.md#using-fxrc) file.
2018-12-02 15:25:56 +00:00
```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
```
2020-09-03 21:54:32 +00:00
Extract values from maps.
```bash
$ fx commits.json | fx .[].author.name
```
2019-12-07 10:09:58 +00:00
Print formatted JSON to stdout.
2018-12-02 15:27:46 +00:00
```bash
$ curl ... | fx .
```
2019-12-07 10:09:58 +00:00
Pipe JSON logs stream into fx.
2019-02-28 16:20:35 +00:00
```bash
$ kubectl logs ... -f | fx .message
```
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
2019-03-07 16:47:04 +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-03-09 05:04:43 +00:00
* [gofx](https://github.com/antonmedv/gofx) 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)