Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8721910
[#306]: Add CLI runtime state
anatoly-scherbakov Aug 28, 2026
48480c7
[#306]: Add CLI error reporting
anatoly-scherbakov Aug 28, 2026
8057ad3
[#306]: Add CLI output writers
anatoly-scherbakov Aug 28, 2026
2ac4a27
[#306]: Add CLI input handling
anatoly-scherbakov Aug 28, 2026
37dd998
[#306]: Add shared CLI options
anatoly-scherbakov Aug 28, 2026
122b164
[#306]: Add CLI commands package
anatoly-scherbakov Aug 28, 2026
e03b436
[#306]: Move cache command
anatoly-scherbakov Aug 28, 2026
0991741
[#306]: Move get command
anatoly-scherbakov Aug 28, 2026
608de78
[#306]: Move expand command
anatoly-scherbakov Aug 28, 2026
895cb74
[#306]: Add compact command
anatoly-scherbakov Aug 28, 2026
3eebff0
[#306]: Add flatten command
anatoly-scherbakov Aug 28, 2026
eca3af1
[#306]: Add frame command
anatoly-scherbakov Aug 28, 2026
84bbea6
[#306]: Add to-rdf command
anatoly-scherbakov Aug 28, 2026
1795acd
[#306]: Add from-rdf command
anatoly-scherbakov Aug 28, 2026
b2ab7a6
[#306]: Assemble CLI application
anatoly-scherbakov Aug 28, 2026
1422d81
[#306]: Split CLI application modules
anatoly-scherbakov Aug 28, 2026
605dfcd
[#306]: Correct CLI option documentation
anatoly-scherbakov Aug 28, 2026
e673161
[#306]: Package CLI command modules
anatoly-scherbakov Aug 28, 2026
bd9d8b5
[#306]: Lint CLI modules
anatoly-scherbakov Aug 28, 2026
bdd272b
[#306]: Cover complete CLI transformations
anatoly-scherbakov Aug 28, 2026
ba4ee41
[#306]: Add CLI context fixture
anatoly-scherbakov Aug 28, 2026
018ca3e
[#306]: Add CLI frame fixture
anatoly-scherbakov Aug 28, 2026
202a57f
[#306]: Add CLI N-Quads fixture
anatoly-scherbakov Aug 28, 2026
6bf7b9b
[#306]: Document compact command
anatoly-scherbakov Aug 28, 2026
9f09a28
[#306]: Document flatten command
anatoly-scherbakov Aug 28, 2026
b9b635a
[#306]: Document frame command
anatoly-scherbakov Aug 28, 2026
4d36c96
[#306]: Document to-rdf command
anatoly-scherbakov Aug 28, 2026
7bfe74c
[#306]: Document from-rdf command
anatoly-scherbakov Aug 28, 2026
7cc084c
[#306]: Register CLI command pages
anatoly-scherbakov Aug 28, 2026
7440dec
[#306]: List CLI transformations
anatoly-scherbakov Aug 28, 2026
27ba195
[#306]: Document CLI transformations
anatoly-scherbakov Aug 28, 2026
da8c486
[#306]: Announce complete CLI transformations
anatoly-scherbakov Aug 28, 2026
239a167
[#306]: Document frame embed default as @once
anatoly-scherbakov Aug 31, 2026
0841f4c
[#306]: Document CLI tests
anatoly-scherbakov Aug 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
`identifierIssuer` option with an `IdentifierIssuer` instance for blank node
identifiers. Defaults to `IdentifierIssuer('_:b')`, which preserves the
previous behaviour.
- `pyld` command-line tool (`get`, `expand`, `cache clear`), installed via
`pip install "PyLD[cli]"`, with remote contexts cached in a CLI-specific
SQLite file (overridable via `--cache-file` / `PYLD_CACHE_FILE`).
- `pyld` command-line tool (`get`, `expand`, `compact`, `flatten`, `frame`,
`to-rdf`, `from-rdf`, and `cache clear`), installed via
`pip install "PyLD[cli]"`. Remote contexts are cached in a CLI-specific SQLite
file (overridable via `--cache-file` / `PYLD_CACHE_FILE`).

## 3.2.0 - 2026-08-17

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ upgrade-submodules:
download-bundled-contexts:
python scripts/download_contexts.py

RUFF_TARGET = lib/pyld/*.py tests/*.py docs_macros.py
RUFF_TARGET = lib/pyld/*.py lib/pyld/cli/*.py lib/pyld/cli/commands/*.py tests/*.py docs_macros.py

lint:
ruff check $(RUFF_TARGET)
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,20 @@ or define the requirement as `PyLD[requests]` or `PyLD[aiohttp]`.

## Command line

Install the optional CLI extra to get a `pyld` console script:
Install the optional CLI extra to get a JSON-LD 1.1 `pyld` console script:

```bash
pip install "PyLD[cli]"
pyld expand document.jsonld
pyld expand https://example.com/doc.jsonld
pyld compact document.jsonld context.jsonld
pyld frame document.jsonld frame.jsonld
pyld to-rdf document.jsonld
pyld from-rdf document.nq
```

See the [CLI documentation](https://digitalbazaar.github.io/pyld/cli/).
The CLI also provides `get`, `flatten`, and HTTP cache management. See the
[CLI documentation](https://digitalbazaar.github.io/pyld/cli/) for all commands,
options, and stdin support.

## Usage

Expand Down
5 changes: 5 additions & 0 deletions docs/cli/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ nav:
- index.md
- get.md
- expand.md
- compact.md
- flatten.md
- frame.md
- to-rdf.md
- from-rdf.md
- cache.md
32 changes: 32 additions & 0 deletions docs/cli/compact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
hide: [toc]
---

# :material-arrow-collapse: `pyld compact`

!!! warning "Requires `pip install PyLD[cli]`"

Compact a JSON-LD document using a required context. `INPUT` accepts a path,
URL, or `-`; `CONTEXT` accepts a path, URL, or `-`. Only one operand may read
from standard input.

::: mkdocs-typer2
:module: pyld.cli
:name: pyld
:command: compact
:termynal: true
:width: 88

## Example

=== "Example"

{{ terminal('pyld compact docs/examples/data/person.jsonld docs/examples/data/context.jsonld', indent=4) }}

=== "person.jsonld"

{{ example_data('data/person.jsonld', indent=4) }}

=== "context.jsonld"

{{ example_data('data/context.jsonld', indent=4) }}
26 changes: 26 additions & 0 deletions docs/cli/flatten.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
hide: [toc]
---

# :material-format-list-group: `pyld flatten`

!!! warning "Requires `pip install PyLD[cli]`"

Flatten a JSON-LD document. Add `--context` to compact the flattened output.

::: mkdocs-typer2
:module: pyld.cli
:name: pyld
:command: flatten
:termynal: true
:width: 88

## Example

=== "Example"

{{ terminal('pyld flatten docs/examples/data/person.jsonld', indent=4) }}

=== "person.jsonld"

{{ example_data('data/person.jsonld', indent=4) }}
32 changes: 32 additions & 0 deletions docs/cli/frame.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
hide: [toc]
---

# :material-image-frame: `pyld frame`

!!! warning "Requires `pip install PyLD[cli]`"

Frame a JSON-LD document using a required frame. `INPUT` accepts a path, URL,
or `-`; `FRAME` accepts a path, URL, or `-`. Only one operand may read from
standard input.

::: mkdocs-typer2
:module: pyld.cli
:name: pyld
:command: frame
:termynal: true
:width: 88

## Example

=== "Example"

{{ terminal('pyld frame docs/examples/data/person.jsonld docs/examples/data/frame.jsonld', indent=4) }}

=== "person.jsonld"

{{ example_data('data/person.jsonld', indent=4) }}

=== "frame.jsonld"

{{ example_data('data/frame.jsonld', indent=4) }}
27 changes: 27 additions & 0 deletions docs/cli/from-rdf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
hide: [toc]
---

# :material-import: `pyld from-rdf`

!!! warning "Requires `pip install PyLD[cli]`"

Convert raw N-Quads from a local path or `-` into JSON-LD. Remote RDF input is
not supported.

::: mkdocs-typer2
:module: pyld.cli
:name: pyld
:command: from-rdf
:termynal: true
:width: 88

## Example

=== "Example"

{{ terminal('pyld from-rdf docs/examples/data/person.nq', indent=4) }}

=== "person.nq"

{{ example_data('data/person.nq', indent=4) }}
38 changes: 37 additions & 1 deletion docs/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ icon: material/console

!!! warning "Requires `pip install PyLD[cli]`"

PyLD ships a `pyld` command-line tool for JSON-LD transformations.
PyLD ships a `pyld` command-line tool for JSON-LD 1.1 transformations.

JSON-LD inputs accept a local path, URL, or explicit `-` for standard input.
Contexts and frames accept a local path, URL, or `-`. Only one operand in an
invocation may consume standard input. Raw N-Quads input accepts only a local
path or `-`, and N-Quads output is written directly to standard output without
JSON quoting or terminal styling.

<div class="grid cards" markdown>

Expand All @@ -23,6 +29,36 @@ PyLD ships a `pyld` command-line tool for JSON-LD transformations.

Expand a JSON-LD document into full IRI-based form.

- [:material-arrow-collapse:{ .lg .middle } `pyld compact`](compact.md)

---

Compact a JSON-LD document using a context.

- [:material-format-list-group:{ .lg .middle } `pyld flatten`](flatten.md)

---

Flatten a JSON-LD document into a single node map.

- [:material-image-frame:{ .lg .middle } `pyld frame`](frame.md)

---

Frame a JSON-LD document into a selected tree shape.

- [:material-export:{ .lg .middle } `pyld to-rdf`](to-rdf.md)

---

Convert JSON-LD to raw N-Quads.

- [:material-import:{ .lg .middle } `pyld from-rdf`](from-rdf.md)

---

Convert raw N-Quads to JSON-LD.

- [:material-cached:{ .lg .middle } `pyld cache`](cache.md)

---
Expand Down
26 changes: 26 additions & 0 deletions docs/cli/to-rdf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
hide: [toc]
---

# :material-export: `pyld to-rdf`

!!! warning "Requires `pip install PyLD[cli]`"

Convert JSON-LD to raw N-Quads. `INPUT` accepts a path, URL, or `-`.

::: mkdocs-typer2
:module: pyld.cli
:name: pyld
:command: to-rdf
:termynal: true
:width: 88

## Example

=== "Example"

{{ terminal('pyld to-rdf docs/examples/data/person.jsonld', indent=4) }}

=== "person.jsonld"

{{ example_data('data/person.jsonld', indent=4) }}
5 changes: 5 additions & 0 deletions docs/examples/data/context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"@context": {
"name": "http://schema.org/name"
}
}
5 changes: 5 additions & 0 deletions docs/examples/data/frame.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"@context": {
"name": "http://schema.org/name"
}
}
1 change: 1 addition & 0 deletions docs/examples/data/person.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<http://example.com/ada> <http://schema.org/name> "Ada Lovelace" .
Loading
Loading