Skip to content

Add --context option to format. #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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: 7 additions & 0 deletions bin/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ function _jsonLdOptions(command, input) {
options.safe = true;
}

if(command.context) {
options.expandContext = command.context;
}

options.base = _getBase(command, input);

// setup documentLoader
Expand Down Expand Up @@ -253,6 +257,7 @@ program

_jsonLdCommand(program.command('format [filename|URL|-]'))
.description('format and convert JSON-LD')
.option('-c, --context <filename|URL>', 'context filename or URL')
.option('-f, --format <format>', 'output format [json]', String)
.option('-q, --n-quads', 'output application/n-quads [false]')
.option('-j, --json', 'output application/json [true]')
Expand Down Expand Up @@ -297,6 +302,7 @@ _jsonLdCommand(program.command('format [filename|URL|-]'))

_jsonLdCommand(program.command('lint [filename|URL|-]'))
.description('lint JSON-LD')
.option('-c, --context <filename|URL>', 'context filename or URL')
.action(async function lint(input, cmd) {
input = input || '-';
const options = _jsonLdOptions(cmd, input);
Expand Down Expand Up @@ -329,6 +335,7 @@ _jsonLdCommand(program.command('compact [filename|URL]'))

_jsonLdCommand(program.command('expand [filename|URL|-]'))
.description('expand JSON-LD')
.option('-c, --context <filename|URL>', 'context filename or URL')
.option(' --keep-free-floating-nodes', 'keep free-floating nodes')
.action(async function expand(input, cmd) {
input = input || '-';
Expand Down