Conversation
When clang-format, introduced in #2652, applied its changes to MRtrix3 code relating to the command-line interface (particularly the way that options and their arguments are concatenated through the addition operator), the resulting code was often quite ugly. This commit replaces code relating to CLI configuration (both the usage() function in cmd/*.cpp, and in definitions of options and option groups utilised by multiple commands) with manually formatted code, and includes comment fields to disable further manipulation of that code by clang-format.
|
Line count is a little gratuitous; will need to refactor and put the bulk of changes under the MRtrixBot account. |
|
LGTM, modulo the fact that sometimes you've missed a space in |
| Argument("option").type_choice(file_outputs) | ||
| + Option ("files", "select how the resulting streamlines will be grouped in output files." | ||
| " Options are: per_edge, per_node, single (default: per_edge)") | ||
| + Argument ("option").type_choice (file_outputs) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+ Argument ("option").type_choice (file_outputs)
^| + Argument ("input", "the input connectome.").type_text () | ||
|
|
||
| + Argument ("operation", "the operation to apply," | ||
| " one of: " + join(operations, ", ") + ".").type_choice (operations) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
" one of: " + join(operations, ", ") + ".").type_choice (operations)
^| + Argument ("input", "the input connectome.").type_text () | ||
|
|
||
| + Argument ("operation", "the operation to apply," | ||
| " one of: " + join(operations, ", ") + ".").type_choice (operations) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
" one of: " + join(operations, ", ") + ".").type_choice (operations)
^| join(algorithms, ", ")) | ||
| .type_choice(algorithms) | ||
| + Argument ("algorithm", "the algorithm to use in network-based clustering/enhancement." | ||
| " Options are: " + join(algorithms, ", ")).type_choice (algorithms) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
" Options are: " + join(algorithms, ", ")).type_choice (algorithms)
^| join(algorithms, ", ")) | ||
| .type_choice(algorithms) | ||
| + Argument ("algorithm", "the algorithm to use in network-based clustering/enhancement." | ||
| " Options are: " + join(algorithms, ", ")).type_choice (algorithms) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
" Options are: " + join(algorithms, ", ")).type_choice (algorithms)
^| + Option ("transform", "transform vertices from one coordinate space to another," | ||
| " based on a template image;" | ||
| " options are: " + join(transform_choices, ", ")) | ||
| + Argument ("mode").type_choice (transform_choices) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+ Argument ("mode").type_choice (transform_choices)
^| Argument("output", "the output mesh file").type_file_out(); | ||
| + Argument ("input", "the input mesh file").type_file_in() | ||
| + Argument ("filter", "the filter to apply;" | ||
| " options are: smooth").type_choice (filters) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
" options are: smooth").type_choice (filters)
^| "- 'mean': unbiased but loss of resolution for individual images possible; " | ||
| "- 'max': smallest voxel size of any input image defines the resolution." | ||
| " Default: mean") | ||
| + Argument ("type").type_choice (resolution_choices) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+ Argument ("type").type_choice (resolution_choices)
^| colourmap_choices_std.push_back(lowercase(entry->name)); | ||
| ++entry; | ||
| } while (entry->name); | ||
| } while(entry->name); |
There was a problem hiding this comment.
warning: implicit conversion 'const char *' -> bool [readability-implicit-bool-conversion]
| } while(entry->name); | |
| } while(entry->name != nullptr); |
| " appropriate for images acquired using 2D stack-of-slices approaches." | ||
| " The 3d mode corresponds to the 3D volume-wise extension proposed by Bautista et al.," | ||
| " which is appropriate for images acquired using 3D Fourier encoding.") | ||
| + Argument ("type").type_choice(modes) |
There was a problem hiding this comment.
warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
+ Argument ("type").type_choice(modes)
^|
I've put off installing the pre-commit hook / format on save because there's a lot of branches that I still need to explicitly transition from pre-clang-format code. I do however need to get into the habit of running it explicitly. Not so concerned on commits like this one; it's moreso not wanting 200 clang-format-related commits on 100 different branches all making their way into the history. |
When clang-format, introduced in #2652, applied its changes to MRtrix3 code relating to the command-line interface (particularly the way that options and their arguments are concatenated through the addition operator), the resulting code was often quite ugly. This commit replaces code relating to CLI configuration (both the usage() function in cmd/*.cpp, and in definitions of options and option groups utilised by multiple commands) with manually formatted code, and includes comment fields to disable further manipulation of that code by clang-format. This commit is a refactor of 0cec87a generated as part of #2815, with the changes being to omit other modifications to the command documentation that are not directly related to clang-format (those changes are in the parent commit to this commit: 15e253c), and to change authorship of the commit.
|
Replaced by #2818. |
Partial reversion of #2652; though it's not "reverted" so much as replaced with manually formatted code.
Upon attempting to commence #2138 I found the reformatted
usage()code so unbearable that I committed to refactoring all of the affected code.I've tried to follow something resembling standards in terms of code formatting, including reducing text width even if column size isn't going to be enforced within these blocks of code. I also took the opportunity to tweak certain command documentation as I was going; shouldn't be anything controversial.
Could do with a fresh set of eyes over the manifest changes to the online command documentation just to be sure I've not broken anything.