Git Product home page Git Product logo

jmespath.terminal's Introduction

JMESPath Terminal

JMESPath, in your terminal!

image

Overview

JMESPath is an expression language for manipulating JSON documents. If you've never heard of JMESPath before, you write a JMESPath expression that when applied to an input JSON document will produces an output JSON document based on the expression you've provided.

You can check out the JMESPath site for more information.

One of the best ways to learn the JMESPath language is to experiment by creating your own JMESPath expressions. The JMESPath Terminal makes it easy to see the results of your JMESPath expressions immediately as you type.

Getting Started

You can install the JMESPath Terminal via pip:

$ pip install jmespath-terminal

There will then be a jpterm program you can run:

$ jpterm

With no arguments specified, a sample JSON document is used as input.

You can also specify an initial JSON document to use by specifying the JSON file as a positional argument:

$ jpterm /tmp/somejsondoc.json

You can also pipe an input JSON document into the jpterm command:

image

Output

When the jpterm program exits (via F5 or Ctrl-c), jpterm may write content to stdout depending on the output mode. There are three output modes:

  • result - Whatever is in the "JMESPath result" pane (the right hand side) will be printed to stdout.
  • expression - Whatever is in the "JMESPath expression" pane is printed to stdout.
  • nothing - Nothing is written to stdout when exiting.

The default mode is "result", which means that by default, whatever is in the result pane will be printed to stdout when jpterm exits. You can switch output modes using Ctrl-p, which will cycle through the three modes above. You can also specify what mode to use when starting the jpterm command using the -m/--output-mode command line option.

Keyboard Shortcuts

F5 or Ctrl + c
Quit the program.
Ctrl + p
Output mode toggle. Toggle between outputting the current result,
expression, or nothing. This is discussed in the "Output" section above.
Ctrl + ]
Clear the current expression.

Mouse Clicks

NOTE: These features are dependent on terminal support. (The Terminal.app included in Mac OS X does not support this, but iTerm2 does.)

One feature of the Urwid Python package (which jmespath-terminal is built on) is that mouse clicks are recognized. This allows you to click to switch focus on either the Input or Result window (and of course back to the Expression) and scroll it.

This can make it difficult to select text for copying/pasting. Many Linux terminals will allow you to select the text with a Shift + click/drag and copy it with Shift + Ctrl + c. In iTerm2 selections can be made with Opt/Alt + click/drag.

Working on JMESPath Terminal

If you like to work on jmespath-terminal to add new features, you can first create and activate a new virtual environment:

$ virtualenv venv
$ . venv/bin/activate

Then install the module:

$ pip install -e .

You'll now be able to modify the jpterm.py module and see your changes reflected when you run the jpterm command.

jmespath.terminal's People

Contributors

brandond avatar jamesls avatar kit494way avatar richardbronosky avatar springcomp avatar

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.