• This repository has been archived on 03/Mar/2022
  • Stars
    star
    233
  • Rank 165,933 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐾 fx-like command-line JSON processing tool

gofx Build Status

fx-like command-line JSON processing tool. This is implementation of some functionality of fx tool.

Features

  • Don't need to learn new syntax
  • Written in Go
  • Formatting and highlighting

Differences

  • Only ES5 (no arrow functions, no spread)
  • Small binary size
  • Can't use npm packages

Install

$ go get github.com/antonmedv/gofx

Or download precompiled binary from releases page.

Usage

Pipe into gofx any JSON and JS code for reducing it.

$ gofx [code ...]

Pretty print JSON without passing any arguments:

$ echo '{"key":"value"}' | gofx
{
    "key": "value"
}

This Binding

You can get access to JSON by this keyword:

$ echo '{"foo": [{"bar": "value"}]}' | gofx 'this.foo[0].bar'
value

Dot

It is possible to omit this keyword:

$ echo '{"foo": [{"bar": "value"}]}' | gofx .foo[0].bar
value

Chain

You can pass any number of code blocks for reducing JSON:

$ echo '{"foo": [{"bar": "value"}]}' | gofx 'this.foo' 'this[0]' 'this.bar'
value

Formatting

If you need something different then JSON (for example arguments for xargs) do not return anything from reducer. undefined value printed into stderr by default.

$ echo '[]' | gofx 'void 0'
undefined
$ echo '[1,2,3]' | gofx 'this.forEach(function (x) { console.log(x) })' 2>/dev/null | xargs echo
1 2 3

Modifying

To modify object use command separated by comma , and return this as the end.

$ echo '{"a": 2}' | gofx 'this["b"] = Math.pow(this.a, 10), this'
{
  "a": 2,
  "b": 1024
}

Object keys

Get all object keys:

$ echo '{"foo": 1, "bar": 2}' | gofx 'Object.keys(this)'
[
  "foo",
  "bar"
]

By the way, gofx has shortcut for Object.keys(this). Previous example can be rewritten as:

$ echo '{"foo": 1, "bar": 2}' | gofx ?

Related

  • fx – original fx package
  • ymlx - fx-like YAML cli processor

License

MIT

More Repositories

1

fx

Terminal JSON viewer
Go
16,770
star
2

expr

Expression language and expression evaluation for Go
Go
3,910
star
3

monkberry

Monkberry is a JavaScript library for building web user interfaces
JavaScript
1,496
star
4

codejar

An embeddable code editor for the browser 🍯
TypeScript
1,489
star
5

red

Terminal log analysis tools
Go
1,436
star
6

llama

Terminal file manager
Go
1,421
star
7

finder

CSS Selector Generator πŸ—Ί
HTML
1,014
star
8

countdown

Terminal countdown timer
Go
948
star
9

numbr

Notepad + calculator
TypeScript
319
star
10

eat

Eats anything, spits out JSON πŸ§€
JavaScript
287
star
11

console

Web PHP Console
PHP
268
star
12

ultra-tiny-compiler

Ultra Tiny Compiler
CoffeeScript
180
star
13

jsize

Find out minified and gzipped npm package size
JavaScript
177
star
14

fx-completion

Bash completion for fx
JavaScript
168
star
15

watch

watch tool rewritten in go
Go
153
star
16

spark

GitHub Stars Sparklines ⚑️
JavaScript
129
star
17

cherimola

A very useful things.
PHP
108
star
18

silicone-skeleton

Silicone Skeleton is Silex Framework Edition Skeleton.
PHP
106
star
19

purephp

PurePHP Key-Value Storage
PHP
88
star
20

tinysh

A tiny spawn wrapper for Node.js
JavaScript
57
star
21

chat

PHP Chat Example
JavaScript
54
star
22

fast-json

Fast extraction of part of JSON
JavaScript
52
star
23

ll

Opinionated ls rewrite in Go 🧦
Go
41
star
24

golang-expression-evaluation-comparison

Go expression evaluation comparison
Go
39
star
25

asciitree

Draw vertical ASCII tree
JavaScript
34
star
26

homer

Internet search engine on React PHP
JavaScript
28
star
27

damka

Russian checkers game
Go
17
star
28

svg-embed

Embed SVG code into DOM. 600 Bytes (gzip)
HTML
16
star
29

year

All unix epoch dates
JavaScript
13
star
30

silicone

Silicone - Organic Silex Framework Edition
PHP
10
star
31

gatsby-source-google-analytics-reporting-api

Gatsby source for Google Anatytics Reporting API
JavaScript
10
star
32

list

Immutable lists in JavaScript without [] and {}
JavaScript
8
star
33

is-it-cloudy

Command line tool to printing weather info 🌦
JavaScript
8
star
34

prettyjson

🧒 Pretty print JSON
JavaScript
8
star
35

fx-theme-monokai

Monokai theme for fx
JavaScript
8
star
36

granula

Granula ORM
PHP
7
star
37

kot

🐱It's a kot!
JavaScript
7
star
38

fx-theme-night

Night theme for fx
JavaScript
6
star
39

mustcheck

Must & Check
Go
5
star
40

find-npm-name

Find available npm name
JavaScript
5
star
41

lazy-chain

lazy-chain is a JavaScript utility library for ES6
JavaScript
5
star
42

morrow

A text-based role-paying game
TypeScript
3
star
43

sshlogger

SSH Logger
Go
3
star
44

numbr.dev

Numbr Private Code
1
star
45

tto

Tic-Tac-Toe game buid with @medv/list
JavaScript
1
star