# jspath-cli

> A small CLI wrapper around jspath.

Latest version **0.1.6** (published 2016-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install jspath-cli
pnpm add jspath-cli
yarn add jspath-cli
bun add jspath-cli
```

Provides the command `jspath`.

## 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.1.6 |
| Published | 2016-03-01 |
| First published | 2016-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Albin Mattsson |
| Maintainers | cstruct |
| Keywords | jspath |

## Links

- npm: https://www.npmjs.com/package/jspath-cli
- Repository: https://github.com/cstruct/jspath-cli
- Homepage: https://github.com/cstruct/jspath-cli#readme
- Issues: https://github.com/cstruct/jspath-cli/issues
- npm.io page: https://npm.io/package/jspath-cli

## Dependencies (2)

- [jspath](https://npm.io/package/jspath.md) latest
- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.1.6 (latest) — 2016-03-01
- 0.1.5 — 2016-03-01
- 0.1.4 — 2016-02-23
- 0.1.3 — 2016-02-21
- 0.1.2 — 2016-02-18
- 0.1.1 — 2016-02-18
- 0.1.0 — 2016-02-18

## README

# jspath-cli
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Build Status](https://travis-ci.org/BoyCook/SpaceUI.png?branch=master)](https://travis-ci.org/cstruct/jspath-cli.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/cstruct/jspath-cli/badge.svg?branch=master)](https://coveralls.io/github/cstruct/jspath-cli?branch=master)

[![Dependency Status](https://david-dm.org/cstruct/jspath-cli.svg)](https://david-dm.org/cstruct/jspath-cli)
[![devDependency Status](https://david-dm.org/cstruct/jspath-cli/dev-status.svg)](https://david-dm.org/cstruct/jspath-cli#info=devDependencies)

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

[![NPM](https://nodei.co/npm/jspath-cli.png)](https://nodei.co/npm/jspath-cli)

A small CLI wrapper around [JSPath](https://npmjs.com/jspath). Support for working with `stdin` and file paths

## Installation

```sh
npm install -g jspath-cli
```

## Usage

With a file path:
```sh
jspath '.some.path' some-file.json
```
With `stdin`:
```sh
cat some-file.json | jspath '.some.path'
```

### Options
- Use `-h` or `--help` to show help output.
- Use `--version` to display program version.
- Use `-p` or `--pretty` to enable pretty printing of output.
- Use `-s` or `--strict` to enable strict mode

### Normal mode
To simplify usage in pipes results always try to be returned in it's most simplified form.
This is done by not wrapping in unnecessary data structures and having singely matched strings printed unquoted.

|matched type|output of single|output of multiple|
|---|---|---|
|Array|Array|Array of arrays' values|
|Object|Object|Array of objects|
|Boolean|Boolean|Array of booleans|
|Number|Number|Array of numbers|
|String|String unquoted|Array of strings|
|Mixed|N/A|Array of mixed|

### Strict mode
By enabling strict mode all results are returned as a valid JSON array of matches.

|matched type|output of single|output of multiple|
|---|---|---|
|Array|Array|Array of arrays' values|
|Object|Array of one object|Array of objects|
|Boolean|Array of one boolean|Array of booleans|
|Number|Array of one number|Array of numbers|
|String|Array of one string unquoted|Array of strings|
|Mixed|N/A|Array of mixed|

## Examples

### Simple
The example from [JSPath](https://npmjs.com/jspath):
```sh
$ echo '
    {
        "automobiles" : [
            { "maker" : "Nissan", "model" : "Teana", "year" : 2011 },
            { "maker" : "Honda", "model" : "Jazz", "year" : 2010 },
            { "maker" : "Honda", "model" : "Civic", "year" : 2007 },
            { "maker" : "Toyota", "model" : "Yaris", "year" : 2008 },
            { "maker" : "Honda", "model" : "Accord", "year" : 2011 }
        ],
        "motorcycles" : [{ "maker" : "Honda", "model" : "ST1300", "year" : 2012 }]
    }' | jspath '.automobiles{.maker === "Honda" && .year > 2009}.model'

['Jazz', 'Accord']
```

### Realworld

JSPath can be used to quickly work with the AWS CLI:
```sh
aws ec2 describe-instances | jspath '
    .Reservations.Instances{
        .Tags.Key === "service" && .Tags.Value === "someservice"
    }.PublicIpAddress{
        . !== "1.2.3.4"
    }'
```

## Support

Please [open an issue](https://github.com/cstruct/jspath-cli/issues/new) for support.

## Contributing

Please contribute by [opening a pull request](https://github.com/cstruct/jspath-cli/compare/).

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