jiq

package module
v0.0.0-...-0248239 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2018 License: MIT Imports: 10 Imported by: 0

README

jiq Mentioned in Awesome jq

It's jid with jq.

You can drill down interactively by using jq filtering queries.

jiq uses jq internally, and it requires you to have jq in your PATH.

If you prefer, there's an experimental, standalone, purely client-side web version of this on https://jq.alhur.es/jiq/.

Demo

screencast-repo.gif

screencast-packagejson.gif

Installation

go get github.com/fiatjaf/jiq/cmd/jiq

If you don't have jq installed, follow instructions at https://stedolan.github.io/jq/download/ and make sure to put it in your PATH.

Usage

Quick start
simple example

Execute the following command:

echo '{"aa":"2AA2","bb":{"aaa":[123,"cccc",[1,2]],"c":321}}'| jiq

Then jiq will be running. Now you can dig JSON data incrementally.

When you enter .bb.aaa[2], you will see the following.

[Filter]> .bb.aaa[2]
[
  1,
  2
]

If you press Enter now it will output

[
  1,
  2
]

and exit (if you want all the output in a single line you can either call jiq -c or pipe it into jq as jiq | jq -c .).

advanced usage examples

If you have ever used jq, you'll be familiar with these:

echo '{"economists": [{"id": 1, "name": "menger"}, {"id": 2, "name": "mises"}, {"name": "hayek", "id": 3}]}' | jiq

Now try writing .economists | "\(.[0].name), \(.[1].name) and \(.[2].name) are economists." or [.economists.[].id], or even .economists | map({key: "\(.id)", value: .name}) | from_entries

with curl

Sample for using RDAP data.

curl -s http://rdg.afilias.info/rdap/domain/example.info | jiq
command line arguments

-q : print the jq filter instead of the resulting filtered JSON to stdout (if you plan to use this with jq later)

Plus all the arguments jq accepts -- they will affect both the JSON output inside jiq and the output that is printed to stdout (beware that some may cause bugs).


traffic analytics for this repo:

Documentation

Index

Constants

View Source
const (
	DefaultY     int    = 1
	FilterPrompt string = "[Filter]> "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(s io.Reader, args []string, initialquery string) *Engine

func (*Engine) Run

func (e *Engine) Run() *EngineResult

type EngineResult

type EngineResult struct {
	Content string
	Qs      string
	Err     error
}

type Query

type Query struct {
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery(query []rune) *Query

func (*Query) Add

func (q *Query) Add(query []rune) []rune

func (*Query) Clear

func (q *Query) Clear() []rune

func (*Query) Delete

func (q *Query) Delete(i int) []rune

func (*Query) Get

func (q *Query) Get() []rune

func (*Query) GetKeywords

func (q *Query) GetKeywords() [][]rune

func (*Query) GetLastKeyword

func (q *Query) GetLastKeyword() []rune

func (*Query) Insert

func (q *Query) Insert(query []rune, idx int) []rune

func (*Query) PopKeyword

func (q *Query) PopKeyword() ([]rune, []rune)

func (*Query) Set

func (q *Query) Set(query []rune) []rune

func (*Query) StringAdd

func (q *Query) StringAdd(query string) string

func (*Query) StringGet

func (q *Query) StringGet() string

func (*Query) StringGetKeywords

func (q *Query) StringGetKeywords() []string

func (*Query) StringGetLastKeyword

func (q *Query) StringGetLastKeyword() string

func (*Query) StringInsert

func (q *Query) StringInsert(query string, idx int) string

func (*Query) StringPopKeyword

func (q *Query) StringPopKeyword() (string, []rune)

func (*Query) StringSet

func (q *Query) StringSet(query string) string

func (*Query) StringSplitLastKeyword

func (q *Query) StringSplitLastKeyword() (string, string)

type Terminal

type Terminal struct {
	// contains filtered or unexported fields
}

func NewTerminal

func NewTerminal(prompt string, defaultY int) *Terminal

type TerminalDrawAttributes

type TerminalDrawAttributes struct {
	Query           string
	CursorOffsetX   int
	Contents        []string
	CandidateIndex  int
	ContentsOffsetY int
	Complete        string
	Candidates      []string
}

Directories

Path Synopsis
cmd
jiq

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL