From 79ab9582a334bab666a611c865ad08ca5a863d6f Mon Sep 17 00:00:00 2001 From: Vizonex Date: Sun, 30 Aug 2026 10:54:15 -0500 Subject: [PATCH 1/3] Attempt to create a simplistic CLI --- cyjs/__main__.py | 33 +++++++++++++++++++++++++++++++++ pyproject.toml | 6 +++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 cyjs/__main__.py diff --git a/cyjs/__main__.py b/cyjs/__main__.py new file mode 100644 index 0000000..544ef3c --- /dev/null +++ b/cyjs/__main__.py @@ -0,0 +1,33 @@ +from pathlib import Path +from typing import Annotated + +from typer import Argument, Option, Typer + +from ._cyjs import Context + +app = Typer() + +@app.command() +def cli( + args:Annotated[list[str] | None, Argument(help="Arguments to pass to quickjs script")] = None, + script: Annotated[Path | None, Option("-C", "--script", help="load module as a script", exists=True)] = None, + eval_code: Annotated[str | None, Option("-e", "--eval", metavar="EVAL", help= "evaluate EXPR")] = None, + strict: bool = False, + backtrace_barrier: bool = False, + promise: bool = False +) -> None: + """A Simplistic script runner for testing code with cyjs""" + + ctx = Context() + if args: + ctx.set_script_arguments(*args) + ctx.add_std_print_handlers() + + if script: + code = script.read_bytes() + ctx.eval_module(code, script.as_posix(), strict, backtrace_barrier, promise) + elif eval_code: + ctx.eval(eval_code, strict=strict, backtrace_barrier=backtrace_barrier, promise=promise) + +if __name__ == "__main__": + app() diff --git a/pyproject.toml b/pyproject.toml index fa7d1f4..5efd2fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,6 @@ authors = [ { name = "Vizonex", email = "VizonexBusiness@gmail.com" } ] requires-python = ">=3.10" -dependencies = [] [tool.cibuildwheel] @@ -28,3 +27,8 @@ version = {attr = "cyjs.__version__"} [project.urls] repository = "https://github.com/Vizonex/cyjs.git" + +[project.optional-dependencies] +cli = [ + "typer>=0.27.2", +] From 24cd416a157c0a6eeb53fe34d76b2c93cb0a8925 Mon Sep 17 00:00:00 2001 From: Vizonex Date: Sun, 30 Aug 2026 11:19:22 -0500 Subject: [PATCH 2/3] add documentation about the commandline and how to install and use it --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 137613d..9d51999 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,27 @@ Installation of cyjs is pretty simplistic and you can get the released version f pip install cyjs ``` +## Running as a Standalone script + +Currently there is a new standalone script if you need +to run javascript directly like with quickjs although +it currently is in it's early phases. It currently uses +[typer]() as a backend (which was developed by the same people who wrote fastapi which is another popular python package). + +``` +pip install cyjs[cli] +``` + +### Using the cli + +It should not be difficult although cyjs is still not very mature yet but hopefully the commandline will help to patch a few bugs or make it easier to test different aspects of quickjs-ng. + +``` +py -m cyjs -e "console.log('Hello Vizonex');" +Hello Vizonex +``` + + ### Using Unreleased Development Versions If your planning to contribute or want in on anything newly added you can clone the github repo there is however one From 9223a9a206d6e959041cf60dbd4fad34ed843af3 Mon Sep 17 00:00:00 2001 From: Vizonex Date: Sun, 30 Aug 2026 11:20:35 -0500 Subject: [PATCH 3/3] add typer's website --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d51999..091544f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ pip install cyjs Currently there is a new standalone script if you need to run javascript directly like with quickjs although it currently is in it's early phases. It currently uses -[typer]() as a backend (which was developed by the same people who wrote fastapi which is another popular python package). +[typer](https://typer.tiangolo.com/) as a backend (which was developed by the same people who wrote fastapi which is another popular python package). ``` pip install cyjs[cli]