# lobar

> A thin shell wrapper for lodash.chain()

Latest version **0.9.5** (published 2016-05-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install lobar
pnpm add lobar
yarn add lobar
bun add lobar
```

Provides the command `lbr`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.5 |
| Published | 2016-05-27 |
| First published | 2016-04-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | joe moon |
| Maintainers | sodiumjoe |
| Keywords | lodash, shell, bash, jq, pipe, unix, json |

## Links

- npm: https://www.npmjs.com/package/lobar
- Repository: https://github.com/sodiumjoe/lobar
- Homepage: https://github.com/sodiumjoe/lobar#readme
- Issues: https://github.com/sodiumjoe/lobar/issues
- npm.io page: https://npm.io/package/lobar

## Dependencies (10)

- [rxjs](https://npm.io/package/rxjs.md) ^5.0.0-beta.7
- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [yargs](https://npm.io/package/yargs.md) ^4.6.0
- [lodash](https://npm.io/package/lodash.md) ^4.11.1
- [triejs](https://npm.io/package/triejs.md) ^0.1.5
- [copy-paste](https://npm.io/package/copy-paste.md) ^1.2.0
- [maquillage](https://npm.io/package/maquillage.md) 0.0.4
- [common-tags](https://npm.io/package/common-tags.md) ^0.1.1
- [shell-quote](https://npm.io/package/shell-quote.md) ^1.6.0
- [decode-keypress](https://npm.io/package/decode-keypress.md) 0.0.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.9.5 (latest) — 2016-05-27
- 0.9.4 — 2016-05-27
- 0.9.3 — 2016-05-21
- 0.9.2 — 2016-05-20
- 0.9.1 — 2016-05-18
- 0.9.0 — 2016-05-18
- 0.8.1 — 2016-05-11
- 0.8.0 — 2016-05-11
- 0.7.0 — 2016-05-11
- 0.6.9 — 2016-05-10
- 0.6.8 — 2016-05-09
- 0.6.7 — 2016-05-09
- 0.6.6 — 2016-05-09
- 0.6.5 — 2016-05-09
- 0.6.4 — 2016-05-06
- … 15 more at https://npm.io/package/lobar/versions

## README

# lobar

A thin shell wrapper for [lodash.chain()](https://lodash.com/).

## install

```shell
> npm install -g lobar
```

## usage

```shell
> lbr -h

Usage: lbr <JSON> <method> <arg> [method arg, ...] [options]

Options:
  -d, --data         <required> input json  [string]
  -f, --filename     <required> input json file  [string]
  -v, --verbose      verbosity level  [count]
  -p, --prettyPrint  pretty print output  [boolean]
  -i, --interactive  interactive mode  [boolean]
  -h, --help         Show help  [boolean]
  -V, --version      Show version number  [boolean]

Examples:
  lbr -d '["foo"]' map upperCase       ["FOO"]
  echo '{"foo": "bar"}' | lbr get foo  "bar"
  echo '{"foo": "bar"}' | lbr .foo     "bar"
```

### pipe

```shell
$ echo '[{"foo":"bar"}, {"foo":"baz"}]' | lbr map foo
> ["bar","baz"]
```

You also have access to lodash methods inside of the method calls:

```shell
$ echo '[{"foo":"bar"}, {"foo": 3}]' | lbr filter 'x => isString(x.foo)'
> [{"foo":"bar"}]
```

### shorthands

A leading `.` on an argument is shorthand for `get`:

```shell
$ echo '{"foo": {"bar": "baz"}}' | lbr .foo.bar
> "baz"
```

is equivalent to:

```shell
$ echo '{"foo": {"bar": "baz"}}' | lbr get foo.bar
> "baz"
```

### interactive mode

```shell
$ curl https://registry.npmjs.com/lobar | lbr -i
```

![interactive mode gif](https://raw.githubusercontent.com/sodiumjoe/lobar/master/lobar.gif)

#### vi keybindings

Interactive mode has basic vi keybindings. It starts in `insert` mode.

##### autocompletion

In insert mode, lobar will try to infer methods or argument from method/arg
position and evaluated JSON at the current cursor position. `<Tab>`/`<S-Tab>` or
`<C-n>`/`<C-p>` to navigate the completion list.

##### normal mode

Hitting `esc` will drop you into normal mode, where you can move horizontally
with `h`, `l`, `b`, `w`, `e`, `t`, `f`, `T`, `F`, `0`, and `$`. You can also use
`c` and `d` with those movements in addition to `i` and `a` with a character or
one of `{}[]{}'"`. Vertical movement ('j', 'k', `<C-d>`, `<C-u>`), will scroll the
json output.

`u` to undo and `<C-r>` to redo.

`y` will copy your current prompt input to your clipboard.

`<C-c>` to exit or `enter` to exit and print the currently evaluated json to
`stdout`.

### caveats

If you want to use a string argument for a method that collides with a lodash
method name, you'll have to quote it twice:

```shell
echo '[{"isString": true}]' | lbr filter "'isString'"
[{"isString":true}]
```

This is because `lbr` tries to `eval` the argument with lodash as the context.

```shell
echo '[{"isString": true}]' | lbr filter isString
[]
```

### environment variables

You can set options using environment variables:

```shell
$ LOBAR_PRETTY_PRINT=true lbr -d '{"foo": "bar"}' .foo
> "bar"
```

## why?

I really like [jq](https://stedolan.github.io/jq/), but I have to look up the
syntax all the time. As a javascript developer, I already know lodash, and it's
generally enough for what I want to do at the command line.

---
_Source: https://npm.io/package/lobar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
