Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List field desciptions if field is matching #174

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,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 @@ -952,6 +953,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 @@ -6963,6 +6965,15 @@ bool otp_list_command::execute(device_map &devices) {
} else {
fos << " (bits " << low << "-" << high << ")\n";
}
const otp_field *field = m.field;
lurch marked this conversation as resolved.
Show resolved Hide resolved
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
Loading