Skip to content

Commit

Permalink
List field desciptions if field is matching (#174)
Browse files Browse the repository at this point in the history
* List field desciptions if field matching (fixes #134)
  • Loading branch information
will-v-pi authored Nov 20, 2024
1 parent 2f2e8df commit dcff4d0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ struct _settings {
std::vector<uint32_t> pages;
bool list_pages = false;
bool list_no_descriptions = false;
bool list_field_descriptions = false;
std::vector<std::string> selectors;
uint32_t row = 0;
std::vector<std::string> extra_files;
Expand Down Expand Up @@ -951,6 +952,7 @@ struct otp_list_command : public cmd {
(
option('p', "--pages").set(settings.otp.list_pages) % "Show page number/page row number" +
option('n', "--no-descriptions").set(settings.otp.list_no_descriptions) % "Don't show descriptions" +
option('f', "--field-descriptions").set(settings.otp.list_field_descriptions) % "Show all field descriptions" +
(option('i', "--include") & value("filename").add_to(settings.otp.extra_files)).min(0).max(1) % "Include extra otp definition" + // todo more than 1
(value("selector").add_to(settings.otp.selectors) %
"The row/field selector, each of which can select a whole row:\n\n" \
Expand Down Expand Up @@ -6974,6 +6976,14 @@ bool otp_list_command::execute(device_map &devices) {
} else {
fos << " (bits " << low << "-" << high << ")\n";
}
if ((m.field || settings.otp.list_field_descriptions) && !settings.otp.list_no_descriptions && !f.description.empty()) {
// Only print field descriptors if matching a field, or if list_field_descriptions is set
fos.first_column(indent0);
fos.hanging_indent(0);
fos << "\"" << f.description << "\"";
fos.first_column(0);
fos << "\n";
}
}
}
}
Expand Down

0 comments on commit dcff4d0

Please sign in to comment.