From cf00cc75a33f42691a1cedd381fb0f8cff24095c Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Tue, 16 Sep 2025 16:47:53 +0200 Subject: [PATCH 1/4] Add script to allow installation with pipx --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5baa85a..7f81187 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,8 @@ requires = ["hatchling"] build-backend = "hatchling.build" +[project.scripts] +jsonata = "jsonata.cli.__main__:main" [project] name = "jsonata-python" From ccec198544670c8fe1308cf94c1784d5a9a78bd3 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Tue, 16 Sep 2025 16:55:39 +0200 Subject: [PATCH 2/4] Update README for installation with pipx and CLI usage --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a184baa..1f66920 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The JSONata documentation can be found [here](https://jsonata.org). ## Installation ``` -pip install jsonata-python +pipx install jsonata-python ``` ## Getting Started @@ -39,7 +39,7 @@ A very simple start: The CLI provides the same functionality as the [Dashjoin JSONata CLI](https://github.com/dashjoin/jsonata-cli). ``` -% python3 -m jsonata.cli +% jsonata -h usage: jsonata.cli [-h] [-v] [-e ] [-i ] [-ic ] [-f {auto,json,string}] [-o ] [-oc ] [-time] [-c] [-b ] [-bf ] [-it] [expr] From ff09a55ce2b52a8809b607e78de9081a137f2422 Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Tue, 16 Sep 2025 16:57:22 +0200 Subject: [PATCH 3/4] Update program name for CLI usage --- README.md | 2 +- src/jsonata/cli/__main__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f66920..19f51d8 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The CLI provides the same functionality as the [Dashjoin JSONata CLI](https://gi ``` % jsonata -h -usage: jsonata.cli [-h] [-v] [-e ] [-i ] [-ic ] [-f {auto,json,string}] [-o ] [-oc ] [-time] [-c] [-b ] +usage: jsonata [-h] [-v] [-e ] [-i ] [-ic ] [-f {auto,json,string}] [-o ] [-oc ] [-time] [-c] [-b ] [-bf ] [-it] [expr] diff --git a/src/jsonata/cli/__main__.py b/src/jsonata/cli/__main__.py index 0454fc8..0822342 100644 --- a/src/jsonata/cli/__main__.py +++ b/src/jsonata/cli/__main__.py @@ -32,7 +32,7 @@ def get_options(argv: Optional[list[str]] = None) -> argparse.ArgumentParser: """Parses command-line arguments. """ - parser = argparse.ArgumentParser(prog="jsonata.cli", description="Pure Python JSONata CLI") + parser = argparse.ArgumentParser(prog="jsonata", description="Pure Python JSONata CLI") parser.add_argument( "-v", "--version", action='version', version='%(prog)s 0.6.0') From b7a986953f53cb953ac89f00aed88a66c7ef3a0e Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Tue, 16 Sep 2025 17:01:45 +0200 Subject: [PATCH 4/4] Update CLI examples --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 19f51d8..3333b89 100644 --- a/README.md +++ b/README.md @@ -76,19 +76,19 @@ options: ### Examples ``` -% echo '{"a":"hello", "b":" world"}' | python3 -m jsonata.cli '(a & b)' +% echo '{"a":"hello", "b":" world"}' | jsonata '(a & b)' hello world -% echo '{"a":"hello", "b":" world"}' | python3 -m jsonata.cli -o helloworld.json $ +% echo '{"a":"hello", "b":" world"}' | jsonata -o helloworld.json $ # helloworld.json written -% ls | python3 -m jsonata.cli $ +% ls | jsonata $ helloworld.json -% ps -o pid="",%cpu="",%mem="" | python3 -m jsonata.cli '$.$split(/\n/).$trim().[ $split(/\s+/)[$length()>0].$number() ]' -c +% ps -o pid="",%cpu="",%mem="" | jsonata '$.$split(/\n/).$trim().[ $split(/\s+/)[$length()>0].$number() ]' -c [[4105,0,0],[4646,0,0],[4666,0,0],[33696,0,0]...] -% curl -s https://raw.githubusercontent.com/jsonata-js/jsonata/master/test/test-suite/datasets/dataset1.json | python3 -m jsonata.cli '{"Name": FirstName & " " & Surname, "Cities": **.City, "Emails": Email[type="home"].address}' +% curl -s https://raw.githubusercontent.com/jsonata-js/jsonata/master/test/test-suite/datasets/dataset1.json | jsonata '{"Name": FirstName & " " & Surname, "Cities": **.City, "Emails": Email[type="home"].address}' { "Name": "Fred Smith", "Cities": [ @@ -101,7 +101,7 @@ helloworld.json ] } -% python3 -m jsonata.cli -i helloworld.json -it +% jsonata -i helloworld.json -it Enter an expression to have it evaluated. JSONata> (a & b) hello world