Skip to content

feat(cli): provide executable script for the package #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asopian
Copy link

@asopian asopian commented Apr 29, 2025

Make the package to be executable from the CLI.
And allows transforming input from stdin or from a file (option -f).
Also allows jmespath expression to be given as param or from file (option -e).

Example:

  1. Using stdin
echo '{"hello": "world"}' | jp "hello"    # Output: "world"

Assuming jp_input.json :

{
  "hello": "world"
}

And jp_query :

 hello
  1. Using CLI parameters
jp -f jp_input.json -e jp_query   # Output: "world"

Later on this can be scripted or used with nodemon for continuous exploratory working with JSON transformation.
For example:

npx nodemon --watch jp_query.query --exec "jp -f jp_input.json -e jp_query.query > jp_output.json"

@springcomp
Copy link
Contributor

I like the idea.

@asopian would that benefit from being written in TypeScript ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants