@@ -191,7 +191,9 @@ def validate():
191191 is_flag = True ,
192192 help = "Disable all logging output" ,
193193)
194+ @click .pass_context
194195def validate_bids_cmd (
196+ ctx ,
195197 data_path ,
196198 error_limit ,
197199 errors_by_file ,
@@ -244,7 +246,8 @@ def validate_bids_cmd(
244246 args .append ("-x" )
245247 args .extend (exclude_dirs )
246248
247- validate_bids_main (args )
249+ result = validate_bids_main (args )
250+ ctx .exit (result if result is not None else 0 )
248251
249252
250253@validate .command (
@@ -354,7 +357,9 @@ def validate_bids_cmd(
354357 is_flag = True ,
355358 help = "Disable all logging output" ,
356359)
360+ @click .pass_context
357361def validate_hed_string_cmd (
362+ ctx ,
358363 hed_string ,
359364 schema_version ,
360365 definitions ,
@@ -395,14 +400,16 @@ def validate_hed_string_cmd(
395400 if verbose :
396401 args .append ("-v" )
397402
398- validate_string_main (args )
403+ result = validate_string_main (args )
404+ ctx .exit (result if result is not None else 0 )
399405
400406
401407@schema .command (name = "validate" )
402408@click .argument ("schema_path" , type = click .Path (exists = True ), nargs = - 1 , required = True )
403409@click .option ("--add-all-extensions" , is_flag = True , help = "Always verify all versions of the same schema are equal" )
404410@click .option ("-v" , "--verbose" , is_flag = True , help = "Enable verbose output" )
405- def schema_validate_cmd (schema_path , add_all_extensions , verbose ):
411+ @click .pass_context
412+ def schema_validate_cmd (ctx , schema_path , add_all_extensions , verbose ):
406413 """Validate HED schema files.
407414
408415 This command validates HED schema files for correctness, checking structure,
@@ -434,13 +441,15 @@ def schema_validate_cmd(schema_path, add_all_extensions, verbose):
434441 if verbose :
435442 args .append ("-v" )
436443
437- validate_schemas_main (args )
444+ result = validate_schemas_main (args )
445+ ctx .exit (result if result is not None else 0 )
438446
439447
440448@schema .command (name = "convert" )
441449@click .argument ("schema_path" , type = click .Path (exists = True ), nargs = - 1 , required = True )
442450@click .option ("--set-ids" , is_flag = True , help = "Set/update HED IDs in the schema" )
443- def schema_convert_cmd (schema_path , set_ids ):
451+ @click .pass_context
452+ def schema_convert_cmd (ctx , schema_path , set_ids ):
444453 """Convert HED schema between formats (TSV, XML, MEDIAWIKI, JSON).
445454
446455 This command converts HED schema files between different formats while
@@ -467,14 +476,16 @@ def schema_convert_cmd(schema_path, set_ids):
467476 if set_ids :
468477 args .append ("--set-ids" )
469478
470- convert_main (args )
479+ result = convert_main (args )
480+ ctx .exit (result if result is not None else 0 )
471481
472482
473483@schema .command (name = "add-ids" )
474484@click .argument ("repo_path" , type = click .Path (exists = True ))
475485@click .argument ("schema_name" )
476486@click .argument ("schema_version" )
477- def schema_add_ids_cmd (repo_path , schema_name , schema_version ):
487+ @click .pass_context
488+ def schema_add_ids_cmd (ctx , repo_path , schema_name , schema_version ):
478489 """Add HED IDs to a schema.
479490
480491 This command adds unique HED IDs to schema elements that don't have them,
@@ -498,7 +509,8 @@ def schema_add_ids_cmd(repo_path, schema_name, schema_version):
498509
499510 args = [repo_path , schema_name , schema_version ]
500511
501- add_ids_main (args )
512+ result = add_ids_main (args )
513+ ctx .exit (result if result is not None else 0 )
502514
503515
504516@cli .group ()
@@ -613,8 +625,19 @@ def extract():
613625 is_flag = True ,
614626 help = "Suppress log output to stderr; only applicable when --log-file is used (logs go only to file)" ,
615627)
628+ @click .pass_context
616629def extract_bids_sidecar_cmd (
617- data_path , suffix , value_columns , skip_columns , log_level , log_file , log_quiet , output_file , verbose , exclude_dirs
630+ ctx ,
631+ data_path ,
632+ suffix ,
633+ value_columns ,
634+ skip_columns ,
635+ log_level ,
636+ log_file ,
637+ log_quiet ,
638+ output_file ,
639+ verbose ,
640+ exclude_dirs ,
618641):
619642 """Extract a sidecar template from a BIDS dataset.
620643
@@ -643,7 +666,8 @@ def extract_bids_sidecar_cmd(
643666 args .append ("-x" )
644667 args .extend (exclude_dirs )
645668
646- extract_main (args )
669+ result = extract_main (args )
670+ ctx .exit (result if result is not None else 0 )
647671
648672
649673@extract .command (
@@ -781,7 +805,9 @@ def extract_bids_sidecar_cmd(
781805 is_flag = True ,
782806 help = "Suppress log output to stderr; only applicable when --log-file is used (logs go only to file)" ,
783807)
808+ @click .pass_context
784809def extract_tabular_summary_cmd (
810+ ctx ,
785811 data_path ,
786812 name_prefix ,
787813 name_suffix ,
@@ -834,7 +860,8 @@ def extract_tabular_summary_cmd(
834860 if verbose :
835861 args .append ("-v" )
836862
837- extract_summary_main (args )
863+ result = extract_summary_main (args )
864+ ctx .exit (result if result is not None else 0 )
838865
839866
840867def main ():
0 commit comments