Update README.md

js-version
Anton Medvedev 5 years ago
parent 6b4e7254c5
commit 9713a057c1

@ -14,50 +14,40 @@ Command-line JSON processing tool
* Easy to use
* Standalone binary
* Interactive mode 🎉
* Themes support 🎨
* Streaming support 🌊
* Bash completion
## Install
```
```bash
$ npm install -g fx
```
Or via Homebrew
```
```bash
$ brew install fx
```
Or download standalone binary from [releases](https://github.com/antonmedv/fx/releases) page.
Did you like **fx**? [Buy me a beer 🍺](https://paypal.me/antonmedv) or [send come ₿](https://www.wispay.io/t/ZQb)
## Usage
Start [interactive mode](https://github.com/antonmedv/fx/blob/master/DOCS.md#interactive-mode) without passing any arguments.
```
```bash
$ curl ... | fx
```
Or by passing filename as first argument.
```
$ fx data.json
```
Pipe into `fx` any JSON and anonymous function for reducing it.
```bash
$ curl ... | fx 'json => json.message'
$ fx data.json
```
Or same as above but short.
Pass a few JSON files.
```bash
$ curl ... | fx this.message
$ curl ... | fx .message
cat foo.json bar.json baz.json | fx .message
```
Pass any numbers of arguments as code.
Use full power of JavaScript.
```bash
$ curl ... | fx 'json => json.message' 'json => json.filter(x => x.startsWith("a"))'
$ curl ... | fx '.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.
@ -73,23 +63,16 @@ $ echo '{"count": 0}' | fx '{...this, count: 1}'
}
```
Pretty print JSON with dot.
Print formatted JSON to stdout.
```bash
$ curl ... | fx .
```
Stream JSON into fx.
Pipe JSON logs stream into fx.
```bash
$ kubectl logs ... -f | fx .message
```
Apply fx to a few JSON files.
```bash
$ cat *.json | fx .length
3
4
```
And try this:
```bash
$ fx --life

21
fx.js

@ -116,8 +116,7 @@ module.exports = function start(filename, source, prev = {}) {
})
screen.key(['escape', 'q', 'C-c'], function () {
program.disableMouse() // If exit program immediately, stdin may still receive
setTimeout(() => process.exit(0), 10) // mouse events which will be printed in stdout.
exit()
})
input.on('submit', function () {
@ -424,6 +423,17 @@ module.exports = function start(filename, source, prev = {}) {
hideStatusBar()
})
box.key('p', function () {
screen.destroy()
program.disableMouse()
program.destroy()
setTimeout(() => {
const [text] = print(json)
console.log(text)
process.exit(0)
}, 10)
})
function getLine(y) {
const dy = box.childBase + y
const n = box.getNumber(dy)
@ -637,6 +647,13 @@ module.exports = function start(filename, source, prev = {}) {
screen.render()
}
function exit() {
// If exit program immediately, stdin may still receive
// mouse events which will be printed in stdout.
program.disableMouse()
setTimeout(() => process.exit(0), 10)
}
render()
}

Loading…
Cancel
Save