FEATURE: Command Interface
| Field | Value |
|---|---|
| Version | 20261028 V1 |
| Description | Run jq filters on standard input through the root executable. |
| Depends On | FEATURE-SqlBuiltins.md |
| Provides | ./jq -c |
| Consumes | jq SQL-style builtins and inventory |
Purpose and behavior
Invoke the executable at the application root as ./jq -c '<program>'. Compile the supplied jq program, read JSON values from standard input, and evaluate the program on each input using the shared generator and input stream. Emit each produced value as compact JSON on its own standard-output line, preserving order and multiplicity.
Exit 0 when compilation and execution complete, 3 for a compile or static error, and 5 for a runtime error. Retain values emitted before a runtime error. Send diagnostics to standard error. Only -c is required.
Programmatic Acceptance
=== AC command-stream ===
Intent: The command returns each input unchanged in order as a compact JSON value.
Requires: executable=python3; scope=test
import json import subprocess import sys
values = [{"a": [1, 2]}, [3, 4]] payload = "\n".join(json.dumps(value) for value in values) + "\n" result = subprocess.run(["./jq", "-c", "."], input=payload, capture_output=True, text=True) print(result.stdout) print(result.stderr, file=sys.stderr) assert result.returncode == 0 assert [json.loads(line) for line in result.stdout.splitlines()] == values assert all(line == json.dumps(json.loads(line), separators=(",", ":")) for line in result.stdout.splitlines()) === END AC command-stream ===
=== AC command-errors ===
Intent: Compilation and runtime failures have distinct exit statuses, and prior output survives a runtime failure.
Requires: executable=python3; scope=test
import json import subprocess import sys
invalid = subprocess.run(["./jq", "-c", "{"], input="null", capture_output=True, text=True) print(invalid.stdout) print(invalid.stderr, file=sys.stderr) assert invalid.returncode == 3
value = 7 runtime = subprocess.run( ["./jq", "-c", "., error"], input=json.dumps(value), capture_output=True, text=True ) print(runtime.stdout) print(runtime.stderr, file=sys.stderr) assert runtime.returncode == 5 assert [json.loads(line) for line in runtime.stdout.splitlines()] == [value] === END AC command-errors ===
=== AC command-corpus ===
Intent: Identity programs execute successfully through the command and supplied corpus runner.
Suite: scoped
Requires: executable=python3; scope=test
Probe: --list
import os import re import sys
sys.path.insert(0, "sources") import run_conformance as harness
SELECT = r"^\.$" cases = harness.parse_corpus(harness.CORPUS.read_text(encoding="utf-8")) excluded = harness.apply_exclusions(cases, harness.parse_exclusions(harness.EXCLUSIONS)) selected = [case for case in cases if re.search(SELECT, case.program)] results = [ harness.Result(case, harness.SKIP) if case.line in excluded else harness.run_case(case, [os.path.abspath("jq")], harness.DEFAULT_TIMEOUT) for case in selected ] tally = {status: sum(result.status == status for result in results) for status in (harness.PASS, harness.FAIL, harness.ERROR, harness.SKIP)} for result in results: if result.status in (harness.FAIL, harness.ERROR): print(harness._render_failure(result)) print(f"{tally['pass']} passed, {tally['fail']} failed, {tally['error']} errored") assert sum(tally.values()) > 0, f"selector matched no case: {SELECT}" assert tally["fail"] == 0 and tally["error"] == 0, tally === END AC command-corpus ===
User Acceptance
- None.
Guardrails
- Implement in Python with only standard-library runtime dependencies.
- Do not shell out to system jq or use a third-party jq implementation.
- Do not modify staged source assets.