Skip to content

Commit bc745d7

Browse files
committed
add print flag. Need to figure out how to make datasetPath optional when its used...
1 parent 37ff18c commit bc745d7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/setup/loadSchema.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function merge(obj1, obj2) {
2727
*
2828
* version is ignored when the network cannot be accessed
2929
*/
30-
export async function loadSchema(version?: string, patch?: string): Promise<Schema> {
30+
export async function loadSchema(version?: string, patch?: string, print?: boolean): Promise<Schema> {
3131
let schemaUrl = version
3232
const bidsSchema = typeof Deno !== 'undefined' ? Deno.env.get('BIDS_SCHEMA') : undefined
3333
if (bidsSchema !== undefined) {
@@ -64,6 +64,10 @@ export async function loadSchema(version?: string, patch?: string): Promise<Sche
6464
schema = merge(schema, patchJson)
6565
}
6666

67+
if (print) {
68+
console.log(JSON.stringify(schema))
69+
Deno.exit(0)
70+
}
6771
setCustomMetadataFormats(schema)
6872
return schema
6973
}

src/setup/options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type ValidatorOptions = {
3333
prune?: boolean
3434
maxRows?: number
3535
schemaAddon?: string
36+
printSchema?: boolean
3637
}
3738

3839
const datasetType = new EnumType<string>(
@@ -103,6 +104,10 @@ export const validateCommand: Command<void, void, any, string[], void> = new Com
103104
'--schema-addon <file:string>',
104105
'Json file to be merged with loaded schema.',
105106
)
107+
.option(
108+
'--printSchema',
109+
'Print schema that was loaded and exit.',
110+
)
106111

107112
// Disabling color output is only available in Deno
108113
if (typeof Deno !== 'undefined') {

0 commit comments

Comments
 (0)