diff --git a/README.md b/README.md index a184baa..3333b89 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,8 +39,8 @@ 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 -usage: jsonata.cli [-h] [-v] [-e ] [-i ] [-ic ] [-f {auto,json,string}] [-o ] [-oc ] [-time] [-c] [-b ] +% jsonata -h +usage: jsonata [-h] [-v] [-e ] [-i ] [-ic ] [-f {auto,json,string}] [-o ] [-oc ] [-time] [-c] [-b ] [-bf ] [-it] [expr] @@ -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 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" 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')