Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2bde3b1

Browse files
committedJan 16, 2025·
formatting
1 parent c684155 commit 2bde3b1

File tree

1 file changed

+73
-63
lines changed

1 file changed

+73
-63
lines changed
 

‎cubids/cli.py

+73-63
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _is_file(path, parser):
143143

144144

145145
def _parse_validate():
146-
"""Create and configure the argument parser for the "cubids validate" command.
146+
"""Create and configure the argument parser for the `cubids validate` command.
147147
148148
This function sets up an argument parser with various options for running
149149
the BIDS validator, including specifying the BIDS dataset directory, output
@@ -152,7 +152,7 @@ def _parse_validate():
152152
Returns
153153
-------
154154
argparse.ArgumentParser
155-
Configured argument parser for the "cubids validate" command.
155+
Configured argument parser for the `cubids validate` command.
156156
157157
Parameters
158158
----------
@@ -174,7 +174,7 @@ def _parse_validate():
174174
listed subjects.
175175
"""
176176
parser = argparse.ArgumentParser(
177-
description="cubids-validate: Wrapper around the official BIDS Validator",
177+
description="cubids validate: Wrapper around the official BIDS Validator",
178178
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
179179
)
180180
PathExists = partial(_path_exists, parser=parser)
@@ -244,7 +244,7 @@ def _parse_validate():
244244

245245

246246
def _enter_validate(argv=None):
247-
"""Entry point for the 'cubids-validate' command.
247+
"""Entry point for the `cubids-validate` command.
248248
249249
This function is deprecated and will be removed in the future.
250250
Please use 'cubids validate' instead.
@@ -276,7 +276,7 @@ def _enter_validate(argv=None):
276276

277277

278278
def _parse_bids_version():
279-
"""Parse command-line arguments for the BIDS version command.
279+
"""Parse command-line arguments for the `cubids bids-version` command.
280280
281281
This function sets up an argument parser for the `cubids bids-version` command,
282282
which retrieves the BIDS Validator and Schema version for a given BIDS dataset.
@@ -325,7 +325,11 @@ def _parse_bids_version():
325325

326326

327327
def _enter_bids_version(argv=None):
328-
"""Parses command-line arguments and invokes the `bids_version` workflow.
328+
"""Entry point for the deprecated `cubids-bids-version`.
329+
330+
This function serves as the entry point for the BIDS version command-line
331+
functionality. It parses command-line arguments, issues a deprecation
332+
warning, and invokes the corresponding workflow.
329333
330334
Parameters
331335
----------
@@ -335,16 +339,28 @@ def _enter_bids_version(argv=None):
335339
Returns
336340
-------
337341
None
342+
343+
Warns
344+
-----
345+
DeprecationWarning
346+
Indicates that the `cubids-bids-version` command is deprecated and
347+
will be removed in the future.
338348
"""
349+
warnings.warn(
350+
"cubids-bids-version is deprecated and will be removed in the future. "
351+
"Please use cubids bids-version.",
352+
DeprecationWarning,
353+
stacklevel=2,
354+
)
339355
options = _parse_bids_version().parse_args(argv)
340356
args = vars(options).copy()
341357
workflows.bids_version(**args)
342358

343359

344360
def _parse_bids_sidecar_merge():
345-
"""Create an argument parser for merging BIDS sidecar JSON files.
361+
"""Create an argument parser for the `cubids bids-sidecar-merge` command.
346362
347-
This function sets up an argument parser for the `bids-sidecar-merge` command-line tool,
363+
This function sets up an argument parser for the `cubids bids-sidecar-merge` command-line tool,
348364
which merges critical keys from one BIDS sidecar JSON file into another.
349365
350366
Returns
@@ -385,7 +401,7 @@ def _parse_bids_sidecar_merge():
385401

386402

387403
def _enter_bids_sidecar_merge(argv=None):
388-
"""Entry point for the BIDS sidecar merge command-line interface.
404+
"""Entry point for the deprecated `cubids-enter-bids-sidecar command`.
389405
390406
This function serves as the entry point for the BIDS sidecar merge
391407
functionality. It parses command-line arguments, issues a deprecation
@@ -401,10 +417,6 @@ def _enter_bids_sidecar_merge(argv=None):
401417
DeprecationWarning
402418
Indicates that the `bids-sidecar-merge` command is deprecated and
403419
will be removed in the future.
404-
405-
Notes
406-
-----
407-
This function is intended to be used as a command-line entry point.
408420
"""
409421
warnings.warn(
410422
"bids-sidecar-merge is deprecated and will be removed in the future. "
@@ -418,9 +430,9 @@ def _enter_bids_sidecar_merge(argv=None):
418430

419431

420432
def _parse_group():
421-
"""Parses command-line arguments for the CuBIDS group command.
433+
"""Parse command-line arguments for the `cubids group` command.
422434
423-
This function sets up an argument parser for the `cubids-group` command,
435+
This function sets up an argument parser for the `cubids group` command,
424436
which is used to find key and parameter groups in a BIDS dataset.
425437
426438
Returns
@@ -448,7 +460,7 @@ def _parse_group():
448460
Path to a config file for grouping. If not provided, the default config file from CuBIDS will be used.
449461
"""
450462
parser = argparse.ArgumentParser(
451-
description="cubids-group: find key and parameter groups in BIDS",
463+
description="cubids group: find key and parameter groups in BIDS",
452464
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
453465
)
454466
PathExists = partial(_path_exists, parser=parser)
@@ -502,11 +514,11 @@ def _parse_group():
502514

503515

504516
def _enter_group(argv=None):
505-
"""Handles the entry point for the deprecated 'cubids-group' command.
517+
"""Entry point for the deprecated `cubids-group` command.
506518
507-
This function issues a deprecation warning indicating that 'cubids-group'
519+
This function issues a deprecation warning indicating that `cubids-group`
508520
is deprecated and will be removed in the future. It then parses the
509-
command-line arguments and invokes the 'group' workflow with the parsed
521+
command-line arguments and invokes the `group` workflow with the parsed
510522
arguments.
511523
512524
Parameters
@@ -535,9 +547,9 @@ def _enter_group(argv=None):
535547

536548

537549
def _parse_apply():
538-
"""Parse command-line arguments for the `cubids-apply` command.
550+
"""Parse command-line arguments for the `cubids apply` command.
539551
540-
This function sets up an argument parser for the `cubids-apply` command,
552+
This function sets up an argument parser for the `cubids apply` command,
541553
which applies changes specified in a TSV file to a BIDS directory.
542554
543555
Returns
@@ -565,7 +577,7 @@ def _parse_apply():
565577
Path to a config file for grouping. If not provided, the default config file from CuBIDS will be used.
566578
"""
567579
parser = argparse.ArgumentParser(
568-
description=("cubids-apply: apply the changes specified in a tsv to a BIDS directory"),
580+
description=("cubids apply: apply the changes specified in a tsv to a BIDS directory"),
569581
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
570582
)
571583
PathExists = partial(_path_exists, parser=parser)
@@ -680,7 +692,7 @@ def _enter_apply(argv=None):
680692

681693

682694
def _parse_datalad_save():
683-
"""Create an argument parser for the `cubids-datalad-save` command.
695+
"""Create an argument parser for the `cubids datalad-save` command.
684696
685697
This function sets up an argument parser for performing a DataLad save on a BIDS directory.
686698
It includes arguments for specifying the BIDS directory, a commit message, and an optional
@@ -703,7 +715,7 @@ def _parse_datalad_save():
703715
image tag or Singularity image file.
704716
"""
705717
parser = argparse.ArgumentParser(
706-
description=("cubids-datalad-save: perform a DataLad save on a BIDS directory"),
718+
description=("cubids datalad-save: perform a DataLad save on a BIDS directory"),
707719
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
708720
)
709721
PathExists = partial(_path_exists, parser=parser)
@@ -765,16 +777,16 @@ def _enter_datalad_save(argv=None):
765777

766778

767779
def _parse_undo():
768-
"""Create an argument parser for the 'cubids-undo' command.
780+
"""Create an argument parser for the `cubids undo` command.
769781
770-
This function sets up an argument parser for the 'cubids-undo' command,
782+
This function sets up an argument parser for the `cubids undo` command,
771783
which is used to revert the most recent commit in a BIDS dataset. It
772784
defines the required and optional arguments for the command.
773785
774786
Returns
775787
-------
776788
argparse.ArgumentParser
777-
The argument parser for the 'cubids-undo' command.
789+
The argument parser for the `cubids undo` command.
778790
779791
Parameters
780792
----------
@@ -788,7 +800,7 @@ def _parse_undo():
788800
- container: Docker image tag or Singularity image file.
789801
"""
790802
parser = argparse.ArgumentParser(
791-
description="cubids-undo: revert most recent commit",
803+
description="cubids undo: revert most recent commit",
792804
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
793805
)
794806
PathExists = partial(_path_exists, parser=parser)
@@ -812,9 +824,9 @@ def _parse_undo():
812824

813825

814826
def _enter_undo(argv=None):
815-
"""Handle the 'cubids-undo' command-line interface (CLI) entry point.
827+
"""Entry point for the deprecated `cubids-undo` command.
816828
817-
This function is called when the 'cubids-undo' command is executed.
829+
This function is called when the `cubids-undo` command is executed.
818830
It displays a deprecation warning and then parses the command-line
819831
arguments to execute the undo workflow.
820832
@@ -827,8 +839,8 @@ def _enter_undo(argv=None):
827839
Warns
828840
-----
829841
DeprecationWarning
830-
Indicates that 'cubids-undo' is deprecated and will be removed
831-
in the future. Users should use 'cubids undo' instead.
842+
Indicates that `cubids-undo` is deprecated and will be removed
843+
in the future. Users should use `cubids undo` instead.
832844
833845
Returns
834846
-------
@@ -845,9 +857,9 @@ def _enter_undo(argv=None):
845857

846858

847859
def _parse_copy_exemplars():
848-
"""Parse command-line arguments for the cubids-copy-exemplars script.
860+
"""Parse command-line arguments for the `cubids copy-exemplars` script.
849861
850-
This function sets up an argument parser for the cubids-copy-exemplars script,
862+
This function sets up an argument parser for the `cubids copy-exemplars` script,
851863
which creates and saves a directory with one subject from each Acquisition Group
852864
in the BIDS dataset.
853865
@@ -882,7 +894,7 @@ def _parse_copy_exemplars():
882894
"""
883895
parser = argparse.ArgumentParser(
884896
description=(
885-
"cubids-copy-exemplars: create and save a directory with "
897+
"cubids copy-exemplars: create and save a directory with "
886898
"one subject from each Acquisition Group in the BIDS dataset"
887899
),
888900
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -964,7 +976,7 @@ def _parse_copy_exemplars():
964976

965977

966978
def _enter_copy_exemplars(argv=None):
967-
"""Entry point for the 'cubids-copy-exemplars' command.
979+
"""Entry point for the deprecated `cubids-copy-exemplars` command.
968980
969981
This function is deprecated and will be removed in the future.
970982
It parses command-line arguments and invokes the `copy_exemplars`
@@ -992,9 +1004,9 @@ def _enter_copy_exemplars(argv=None):
9921004

9931005

9941006
def _parse_add_nifti_info():
995-
"""Parse command-line arguments for adding NIfTI information to BIDS dataset sidecars.
1007+
"""Parse command-line arguments for the `cubids add-nifti-info` command.
9961008
997-
This function sets up an argument parser for the `cubids-add-nifti-info` command,
1009+
This function sets up an argument parser for the `cubids add-nifti-info` command,
9981010
which adds information from NIfTI files to the sidecars of each dataset in a BIDS
9991011
directory.
10001012
@@ -1017,7 +1029,7 @@ def _parse_add_nifti_info():
10171029
"""
10181030
parser = argparse.ArgumentParser(
10191031
description=(
1020-
"cubids-add-nifti-info: Add information from nifti"
1032+
"cubids add-nifti-info: Add information from nifti"
10211033
"files to the sidecars of each dataset"
10221034
),
10231035
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -1055,7 +1067,7 @@ def _parse_add_nifti_info():
10551067

10561068

10571069
def _enter_add_nifti_info(argv=None):
1058-
"""Entry point for adding NIfTI information via command line interface.
1070+
"""Entry point for the deprecated `cubids-add-nifti-info` command.
10591071
10601072
This function is deprecated and will be removed in the future.
10611073
Please use `cubids add-nifti-info` instead.
@@ -1087,9 +1099,9 @@ def _enter_add_nifti_info(argv=None):
10871099

10881100

10891101
def _parse_purge():
1090-
"""Parse command-line arguments for the `cubids-purge` command.
1102+
"""Parse command-line arguments for the `cubids purge` command.
10911103
1092-
This function sets up an argument parser for the `cubids-purge` command,
1104+
This function sets up an argument parser for the `cubids purge` command,
10931105
which is used to purge associations from a BIDS dataset. It defines the
10941106
required arguments and options for the command.
10951107
@@ -1111,7 +1123,7 @@ def _parse_purge():
11111123
- `--container`: Docker image tag or Singularity image file.
11121124
"""
11131125
parser = argparse.ArgumentParser(
1114-
description="cubids-purge: purge associations from the dataset",
1126+
description="cubids purge: purge associations from the dataset",
11151127
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
11161128
)
11171129
PathExists = partial(_path_exists, parser=parser)
@@ -1153,10 +1165,10 @@ def _parse_purge():
11531165

11541166

11551167
def _enter_purge(argv=None):
1156-
"""Entry point for the 'cubids-purge' command.
1168+
"""Entry point for the deprecated `cubids-purge` command.
11571169
11581170
This function is deprecated and will be removed in the future.
1159-
Please use 'cubids purge' instead.
1171+
Please use `cubids purge` instead.
11601172
11611173
Parameters
11621174
----------
@@ -1184,16 +1196,16 @@ def _enter_purge(argv=None):
11841196

11851197

11861198
def _parse_remove_metadata_fields():
1187-
"""Create an argument parser for removing metadata fields from a BIDS dataset.
1199+
"""Create an argument parser for the `cubids remove-metadata-fields` command.
11881200
11891201
This function sets up an argument parser for the command-line interface (CLI)
1190-
tool `cubids-remove-metadata-fields`, which is used to delete specified fields
1202+
tool `cubids remove-metadata-fields`, which is used to delete specified fields
11911203
from the metadata of a BIDS dataset.
11921204
11931205
Returns
11941206
-------
11951207
argparse.ArgumentParser
1196-
The argument parser configured for the `cubids-remove-metadata-fields` CLI tool.
1208+
The argument parser configured for the `cubids remove-metadata-fields` CLI tool.
11971209
11981210
Parameters
11991211
----------
@@ -1210,7 +1222,7 @@ def _parse_remove_metadata_fields():
12101222
Docker image tag or Singularity image file.
12111223
"""
12121224
parser = argparse.ArgumentParser(
1213-
description="cubids-remove-metadata-fields: delete fields from metadata",
1225+
description="cubids remove-metadata-fields: delete fields from metadata",
12141226
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
12151227
)
12161228
PathExists = partial(_path_exists, parser=parser)
@@ -1241,10 +1253,10 @@ def _parse_remove_metadata_fields():
12411253

12421254

12431255
def _enter_remove_metadata_fields(argv=None):
1244-
"""Set entrypoint for "cubids-remove-metadata-fields" CLI.
1256+
"""Entry point for the deprecated `cubids-remove-metadata-fields` command.
12451257
12461258
This function serves as the entry point for the deprecated
1247-
"cubids-remove-metadata-fields" command-line interface (CLI). It issues a
1259+
`cubids-remove-metadata-fields` command-line interface (CLI). It issues a
12481260
deprecation warning and then parses the provided arguments to execute the
12491261
`remove_metadata_fields` workflow.
12501262
@@ -1256,15 +1268,14 @@ def _enter_remove_metadata_fields(argv=None):
12561268
Warns
12571269
-----
12581270
DeprecationWarning
1259-
Indicates that the "cubids-remove-metadata-fields" CLI is deprecated and
1260-
will be removed in the future. Users are advised to use "cubids remove-metadata-fields" instead.
1271+
Indicates that the `cubids-remove-metadata-fields` CLI is deprecated and
1272+
will be removed in the future. Users are advised to use `cubids remove-metadata-fields` instead.
12611273
12621274
See Also
12631275
--------
12641276
_parse_remove_metadata_fields : Function to parse the command-line arguments.
12651277
workflows.remove_metadata_fields : Workflow to remove metadata fields.
12661278
"""
1267-
"""Set entrypoint for "cubids-remove-metadata-fields" CLI."""
12681279
warnings.warn(
12691280
"cubids-remove-metadata-fields is deprecated and will be removed in the future. "
12701281
"Please use cubids remove-metadata-fields.",
@@ -1277,15 +1288,15 @@ def _enter_remove_metadata_fields(argv=None):
12771288

12781289

12791290
def _parse_print_metadata_fields():
1280-
"""Create the parser for the "cubids print-metadata-fields" command.
1291+
"""Create the parser for the `cubids print-metadata-fields` command.
12811292
12821293
This function sets up an argument parser for the command that prints all unique metadata fields
12831294
in a BIDS dataset. It defines the required arguments and their types, as well as optional arguments.
12841295
12851296
Returns
12861297
-------
12871298
argparse.ArgumentParser
1288-
The argument parser for the "cubids print-metadata-fields" command.
1299+
The argument parser for the `cubids print-metadata-fields` command.
12891300
12901301
Parameters
12911302
----------
@@ -1299,7 +1310,7 @@ def _parse_print_metadata_fields():
12991310
"""
13001311
"""Create the parser for the "cubids print-metadata-fields" command."""
13011312
parser = argparse.ArgumentParser(
1302-
description="cubids-print-metadata-fields: print all unique metadata fields",
1313+
description="cubids print-metadata-fields: print all unique metadata fields",
13031314
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
13041315
)
13051316
PathExists = partial(_path_exists, parser=parser)
@@ -1323,9 +1334,9 @@ def _parse_print_metadata_fields():
13231334

13241335

13251336
def _enter_print_metadata_fields(argv=None):
1326-
"""Parse command-line arguments and print metadata fields.
1337+
"""Entry point for the deprecated `cubids-print-metadata-fields` command.
13271338
1328-
This function parses the command-line arguments for printing metadata fields,
1339+
This function parses the command-line arguments for `cubids-print-metadata-fields`,
13291340
issues a deprecation warning, and then calls the `print_metadata_fields`
13301341
function from the `workflows` module with the parsed arguments.
13311342
@@ -1373,9 +1384,9 @@ def _enter_print_metadata_fields(argv=None):
13731384

13741385

13751386
def _get_parser():
1376-
"""Create the general "cubids" parser object.
1387+
"""Create the general `cubids` parser object.
13771388
1378-
This function sets up the argument parser for the "cubids" command-line interface.
1389+
This function sets up the argument parser for the `cubids` command-line interface.
13791390
It includes a version argument and dynamically adds subparsers for each command
13801391
defined in the COMMANDS list.
13811392
@@ -1405,7 +1416,7 @@ def _get_parser():
14051416

14061417

14071418
def _main(argv=None):
1408-
"""Set entrypoint for "cubids" CLI.
1419+
"""Set entrypoint for `cubids` CLI.
14091420
14101421
Parameters
14111422
----------
@@ -1416,7 +1427,6 @@ def _main(argv=None):
14161427
-------
14171428
None
14181429
"""
1419-
"""Set entrypoint for "cubids" CLI."""
14201430
options = _get_parser().parse_args(argv)
14211431
args = vars(options).copy()
14221432
args.pop("func")

0 commit comments

Comments
 (0)
Please sign in to comment.