You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLI — after (1) and (2), build a Typer-based pyld tool.
Proposed CLI shape
One Typer command per jsonld API function: expand, compact, flatten, frame, to-rdf, from-rdf, normalize.
Options for each command derived from the matching *Options TypedDict in lib/pyld/options.py.
Input from an optional positional path-or-URL argument, falling back to stdin; JSON or N-Quads on stdout.
Packaging: PyLD[cli] extra
Gate the CLI behind an optional extra so a bare pip install PyLD stays lean:
pip install "PyLD[cli]"
That extra would install typer and register the pyld console script. lib/pyld/cli.py should raise a clear ImportError naming the extra when typer is missing, so a half-installed environment never yields an obscure failure.
Two packaging notes:
setup.py currently imports distutils.core.setup, which silently ignores entry_points. Registering any console script requires switching to setuptools.setup first.
The yaml-ld package on PyPI already installs a pyld console script, so installing both packages in one environment would clash over the executable name.
Loader wiring
The CLI should pass a scheme-dispatching loader (issue #300) as documentLoader per operation, and leave _default_document_loader in lib/pyld/jsonld.py alone. Serving file: by default would let any document with "@context": "file:///etc/passwd" read local files.
Activity
anatoly-scherbakov commentedon Jul 25, 2026
Thanks for the suggestion and for the gist — useful prior art.
A CLI cannot land until local files and remote contexts can both be loaded in one operation. Status:
FileDocumentLoader— in progress on branchfile-document-loader. Servesfile:URLs (and scheme-less absolute paths) only, with optionalrootconfinement.ChoiceBySchemeDocumentLoader, so a local document with a remote@contextcan be processed.pyldtool.Proposed CLI shape
jsonldAPI function:expand,compact,flatten,frame,to-rdf,from-rdf,normalize.*OptionsTypedDict inlib/pyld/options.py.Packaging:
PyLD[cli]extraGate the CLI behind an optional extra so a bare
pip install PyLDstays lean:pip install "PyLD[cli]"That extra would install
typerand register thepyldconsole script.lib/pyld/cli.pyshould raise a clearImportErrornaming the extra whentyperis missing, so a half-installed environment never yields an obscure failure.Two packaging notes:
setup.pycurrently importsdistutils.core.setup, which silently ignoresentry_points. Registering any console script requires switching tosetuptools.setupfirst.yaml-ldpackage on PyPI already installs apyldconsole script, so installing both packages in one environment would clash over the executable name.Loader wiring
The CLI should pass a scheme-dispatching loader (issue #300) as
documentLoaderper operation, and leave_default_document_loaderinlib/pyld/jsonld.pyalone. Servingfile:by default would let any document with"@context": "file:///etc/passwd"read local files.