0.1.6 • Published 8 years ago

jspath-cli v0.1.6

Weekly downloads
37
License
MIT
Repository
github
Last release
8 years ago

jspath-cli

js-standard-style Build Status Coverage Status

Dependency Status devDependency Status

Commitizen friendly

NPM

A small CLI wrapper around JSPath. Support for working with stdin and file paths

Installation

npm install -g jspath-cli

Usage

With a file path:

jspath '.some.path' some-file.json

With stdin:

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 typeoutput of singleoutput of multiple
ArrayArrayArray of arrays' values
ObjectObjectArray of objects
BooleanBooleanArray of booleans
NumberNumberArray of numbers
StringString unquotedArray of strings
MixedN/AArray of mixed

Strict mode

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

matched typeoutput of singleoutput of multiple
ArrayArrayArray of arrays' values
ObjectArray of one objectArray of objects
BooleanArray of one booleanArray of booleans
NumberArray of one numberArray of numbers
StringArray of one string unquotedArray of strings
MixedN/AArray of mixed

Examples

Simple

The example from JSPath:

$ 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:

aws ec2 describe-instances | jspath '
    .Reservations.Instances{
        .Tags.Key === "service" && .Tags.Value === "someservice"
    }.PublicIpAddress{
        . !== "1.2.3.4"
    }'

Support

Please open an issue for support.

Contributing

Please contribute by opening a pull request.

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago