Coder Social home page Coder Social logo

eq's Introduction

Eq

A simple CLI tool for processing EDN data.

Basic usage

$ eq --help

Process EDN data (https://github.com/edn-format/edn) from stdin and
write it to stdout.

Usage: eq [OPTIONS]

  -h, --help             Display this message.
  -c, --compact          Compact output, don't pretty print.
  -r, --readable         Print readable EDN data.
  -d, --dissoc K         Apply #(dissoc % K) to each parsed EDN object.
      --apply-dissoc KS  Apply #(apply dissoc % KS) to each parsed EDN object.
  -g, --get K            Apply #(get % K) to each parsed EDN object.
      --get-in KS        Apply #(get-in % KS) to each parsed EDN object.
  -s, --select-keys KS   Apply #(select-keys % KS) to each parsed EDN object.

Multiple --dissoc, --apply-dissoc, --get, --get-in, --select-keys options may be
passed, in which case the output of each will be on a separate line.

Pretty printing

$ echo '{:id 1 :name "foo" :geo {:country "US" :region "CA"} :date "2000-01-01T00:00:00Z"}' | eq

{:date 2000-01-01T00:00:00Z,
 :name foo,
 :geo {:region CA, :country US},
 :id 1}

Field extraction

$ echo '{:id 1 :name "foo" :geo {:country "US"}}{:id 2 :name "bar" :geo {:country "FR"}}' \
  | eq --get :id --get-in '[:geo :country]' | xargs -n2

1 US
2 FR

Map manipulation

$ echo '{:id 1 :name "foo" :geo {:country "US"}}{:id 2 :name "bar" :geo {:country "FR"}}' \
  | eq --dissoc :geo

{:name foo, :id 1}
{:name bar, :id 2}
$ echo '{:id 1 :name "foo" :geo {:country "US"}}{:id 2 :name "bar" :geo {:country "FR"}}' \
  | eq --apply-dissoc '[:name :geo]'

{:id 1}
{:id 2}
$ echo '{:id 1 :name "foo" :geo {:country "US"}}{:id 2 :name "bar" :geo {:country "FR"}}' \
  | eq --select-keys '[:id :geo]'

{:id 1, :geo {:country US}}
{:id 2, :geo {:country FR}}

Install

Pre-built binaries are available for Linux and MacOS.

License

Copyright © 2014-2020 John Whitbeck

Distributed under the Apache License, Version 2.0.

eq's People

Contributors

jwhitbeck avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.