Giter VIP home page Giter VIP logo

jqp's Introduction

jqp

a TUI playground for exploring jq.

jqp

This application utilizes itchyny's implementation of jq written in Go, gojq.

Installation

homebrew

brew install noahgorstein/tap/jqp

macports

sudo port install jqp

Arch Linux

Available through the Arch User Repository as jqp-bin.

yay -S jqp-bin

Github releases

Download the relevant asset for your operating system from the latest Github release. Unpack it, then move the binary to somewhere accessible in your PATH, e.g. mv ./jqp /usr/local/bin.

Build from source

Clone this repo, build from source with cd jqp && go build, then move the binary to somewhere accessible in your PATH, e.g. mv ./jqp /usr/local/bin.

Usage

➜ jqp --help
jqp is a TUI to explore the jq command line utility

Usage:
  jqp [flags]

Flags:
      --config string   config file (default is $HOME/.jqp.yaml)
  -f, --file string     path to the input JSON file
  -h, --help            help for jqp
  -t, --theme string    jqp theme
  -v, --version         version for jqp

jqp also supports input from STDIN. STDIN takes precedence over the command line flag.

➜ curl "https://api.github.com/repos/stedolan/jq/issues?per_page=2" | jqp 

Keybindings

Keybinding Action
tab cycle through sections
shift-tab cycle through sections in reverse
ctrl-y copy query to system clipboard1
ctrl-s save output to file (copy to clipboard if file not specified)
ctrl-c quit program / kill long running query

Query Mode

Keybinding Action
enter execute query
/ cycle through query history
ctrl-a go to beginning of line
ctrl-e go to end of line
/ctrl-b move cursor one character to left
/ctrl-f move cursor one character to right
ctrl-k delete text after cursor line
ctrl-u delete text before cursor
ctrl-w delete word to left
ctrl-d delete character under cursor

Input Preview and Output Mode

Keybinding Action
↑/k up
↓/j down
ctrl-u page up
ctrl-d page down

Configuration

jqp can be configured with a configuration file. By default, jqp will search your home directory for a YAML file named .jqp.yaml. A path to a YAML configuration file can also be provided to the --config command line flag.

➜ jqp --config ~/my_jqp_config.yaml < data.json

If a configuration option is present in both the configuration file and the command line, the command line option takes precedence. For example, if a theme is specified in the configuration file and via -t/--theme flag, the command line flag will take precedence.

Available Configuration Options

theme:
  name: "nord" # controls the color scheme
  chromaStyleOverrides: # override parts of the chroma style
    kc: "#009900 underline" # keys use the chroma short names

Themes

Themes can be specified on the command line via the -t/--theme <themeName> flag. You can also set a theme in your configuration file.

theme:
  name: "monokai"

Screen Shot 2022-10-02 at 5 31 40 PM

Chroma Style Overrides

Overrides to the chroma styles used for a theme can be configured in your configuration file.

For the list of short keys, see chroma.StandardTypes. To see which token to use for a value, see the JSON lexer (look for <token> tags). To see the color and what's used in the style you're using, look for your style in the chroma styles directory.

theme:
  name: "monokai" # name is required to know which theme to override
  chromaStyleOverrides:
    kc: "#009900 underline"

You can change non-syntax colors using the styleOverrides key:

theme:
  styleOverrides:
    primary: "#c4b28a"
    secondary: "#8992a7"
    error: "#c4746e"
    inactive: "#a6a69c"
    success: "#87a987"

Themes are broken up into light and dark themes. Light themes work best in terminals with a light background and dark themes work best in a terminal with a dark background. If no theme is specified or a non-existant theme is provided, the default theme is used, which was created to work with both terminals with a light and dark background.

Light Themes

  • abap
  • algol
  • arduino
  • autumn
  • borland
  • colorful
  • emacs
  • friendly
  • github
  • gruvbox-light
  • hrdark
  • igor
  • lovelace
  • manni
  • monokai-light
  • murphy
  • onesenterprise
  • paradaiso-light
  • pastie
  • perldoc
  • pygments
  • solarized-light
  • tango
  • trac
  • visual_studio
  • vulcan
  • xcode

Dark Themes

  • average
  • base16snazzy
  • doom-one
  • doom-one2
  • dracula
  • fruity
  • github-dark
  • gruvbox
  • monokai
  • native
  • paradaiso-dark
  • rrt
  • solarized-dark
  • solarized-dark256
  • swapoff
  • vim
  • witchhazel
  • xcode-dark

Built with:

Credits

  • jqq for inspiration

Footnotes

  1. jqp uses https://github.com/atotto/clipboard for clipboard functionality. Things should work as expected with OSX and Windows. Linux, Unix require xclip or xsel to be installed.

jqp's People

Contributors

herbygillot avatar itchyny avatar ktprograms avatar lagerfeuer avatar mluna-again avatar nerg4l avatar nilock avatar noahgorstein avatar noahmayr avatar rvictorino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jqp's Issues

Array not parsed correctly

I noticed that sometimes arrays aren't formatted correctly but when you grab one element it works just fine. Also, when the json isn't able to be parsed the output indicator also shows NaN%
image
image

Output results to stdout

It would be nice if you can output the results to stdout. This way you can use it in a pipe, for example:

jqp <file.json | rg 'something' | vipe >output

Feature Request: Continuous evaluation

Hi there,

this is a nice tool, very similar to @gpanders/ijq which I've been using so far. The main difference (and why I'll be continuing to use ijq for now) is that ijq continually evaluates the expression, not just on Enter. This allows iterating, playing and trying things faster.

Maybe this is something you'd consider having as well? If not as default mode then at least with a hotkey for switching?

Thanks for writing this tool! 🙂

Feature request: vi mode in the editor input box

Love that we have another interactive jq client, thank you for developing it. I was wondering if you'd consider vi mode in the editor input box? In other words, just like one has the ability to switch from the default (emacs) mode on the (*nix) command line to vi mode. See https://readline.kablamo.org/vi.html for background. I'm not sure how many folks use vi mode on the command line, but I do, and it makes things so much faster and more efficient for me, and would be amazing to have that same experience when constructing and editing filters in jqp.

Thanks!

Feature Request: Tiny cheatsheet with examples built-in

Since you're so great implementing my requested features I've got another one for you hahaha 😛
Would be cool to have a tiny cheatsheet built-in with common operations, when you press a hotkey for help.

You could maybe implement this by just rendering a markdown file with all the options, not sure if there is something fancy like that in this go lib. But I think it would be a quick win.

Feature request. Implement session history of executed queries

I think it would be very helpful for users like me, who are not familiar with jq syntax and do many tries and experiments searching for solving their issues.
It would be great if I can select a previously executed query from the dropdown and have the ability to edit it and execute it again.

Layout problem

I use brew to install jqp
Although it can query as normal, but it shows like that.

image

Machine information:
MacOS: Sonoma 14.0
2.3 GHz 4 cores Intel Core i5

iTerm2: Build 3.4.21
jqp version: v0.5.0

Thanks

Feature request: disable cursor blink when terminal window does not have focus

Hello,

Thank you for providing a wonderful tool that I use almost every day! This is a very minor thing, but it would be great if jqp could somehow disable the cursor blinking when the terminal window it's running in does not have focus. My jqp workflow frequently involves toggling between multiple windows on multiple screens and when I see a blinking cursor my brain immediately thinks that window has focus and I'll start typing and entering jqp things that are actually going elsewhere (text editors, web browsers, company Slack channels 🤦‍♂️ , etc.).

Not sure if this is an upstream bubbletea thing, but it would be great to have if possible. Thanks again!

RFC: Configurable Chroma theme overrides

I personally like the vulcan theme, except that the KeywordConstant token uses a grey background.

The ability to override specific parts of a theme in the config file would be nice.

There is a map of TokenType to string in chroma, which can be used in combination with a chroma.StyleBuilder to override specific parts.

For the configuration, I propose a subkey to the theme:, like overrides:. For example:

theme: "vulcan"
  overrides:
    - "kc": "#CF5967"
    - "nf": "#FFFFFF bold"

The quick.Highlight function only supports the chroma style name, so it can't be used with customized styles, but the function itself is only about 28 lines of code (less if we hardcode lexer and formatter), so it's feasible to copy it and allow it to take a chroma.Style directly (the change is also just removing 3 lines).

Copy query to clipboard

It would be really useful to be able to copy the query to clipboard so that I can share the query with others. At the moment, I can't highlight the query and tmux select doesn't work either.

Input file does not has to be valid JSON and should not error

jq can easily handle streams of json objects:

{}
{}
{}

They can for example be wrapped into list with [inputs], where inputs is a keyword for input stream.

It would be great if jqp could load such streams like jq does. For now it fails with an error of invalid JSON.

Debian based release candidate

Hello,
The project makes life so much easier, thanks.
I just want to know if for Ubuntu/Debian Distros should we only make the jqp or it is also possible to install it via package managers?
Best

Support for jsonl

Hi,
It would make jqp more convenient if it could handle jsonl file aka one json per line.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.