log_help: Options can have content

Refactor `PrettyHelp::endgroup()` -> `PrettyHelp::close(int levels = 1)`.
This commit is contained in:
Krystine Sherwin 2025-01-14 15:56:22 +13:00
parent 9cbb17061d
commit 724d71e4a4
No known key found for this signature in database
3 changed files with 27 additions and 15 deletions

View File

@ -84,13 +84,14 @@ void PrettyHelp::usage(const string &usage)
log("\n");
}
void PrettyHelp::option(const string &option, const string &description)
void PrettyHelp::option(const string &text, const string &description)
{
log_pass_str(option, current_indent);
open_option(text);
if (description.length()) {
log_pass_str(description, current_indent+1);
log_pass_str(description, current_indent);
log("\n");
}
close(1);
}
void PrettyHelp::codeblock(const string &code, const string &)
@ -104,13 +105,19 @@ void PrettyHelp::paragraph(const string &text)
log("\n");
}
void PrettyHelp::optiongroup(const string &)
void PrettyHelp::open_optiongroup(const string &)
{
current_indent += 1;
}
void PrettyHelp::endgroup()
void PrettyHelp::open_option(const string &text)
{
current_indent -= 1;
log_pass_str(text, current_indent);
current_indent += 1;
}
void PrettyHelp::close(int levels)
{
current_indent -= levels;
log_assert(current_indent >= 0);
}

View File

@ -38,12 +38,13 @@ public:
bool has_content();
void usage(const string &usage);
void option(const string &option, const string &description = "");
void option(const string &text, const string &description = "");
void codeblock(const string &code, const string &language = "none");
void paragraph(const string &text);
void optiongroup(const string &group = "");
void endgroup();
void open_optiongroup(const string &group = "");
void open_option(const string &text);
void close(int levels = 1);
};
YOSYS_NAMESPACE_END

View File

@ -82,7 +82,7 @@ struct ChformalPass : public Pass {
"given, the command will operate on all constraint types:"
);
help->optiongroup("[types]");
help->open_optiongroup("[types]");
help->option("-assert", "`$assert` cells, representing ``assert(...)`` constraints");
help->option("-assume", "`$assume` cells, representing ``assume(...)`` constraints");
help->option("-live", "`$live` cells, representing ``assert(s_eventually ...)``");
@ -92,11 +92,11 @@ struct ChformalPass : public Pass {
"Additionally chformal will operate on `$check` cells corresponding to the "
"selected constraint types."
);
help->endgroup();
help->close();
help->paragraph("Exactly one of the following modes must be specified:");
help->optiongroup("[mode]");
help->open_optiongroup("[mode]");
help->option("-remove", "remove the cells and thus constraints from the design");
help->option("-early",
"bypass FFs that only delay the activation of a constraint. When inputs "
@ -105,14 +105,17 @@ struct ChformalPass : public Pass {
);
help->option("-delay <N>", "delay activation of the constraint by <N> clock cycles");
help->option("-skip <N>", "ignore activation of the constraint in the first <N> clock cycles");
help->option("-coverenable",
help->open_option("-coverenable");
help->paragraph(
"add cover statements for the enable signals of the constraints"
);
#ifdef YOSYS_ENABLE_VERIFIC
"\n\n"
help->paragraph(
"Note: For the Verific frontend it is currently not guaranteed that a "
"reachable SVA statement corresponds to an active enable signal."
#endif
);
#endif
help->close();
help->option("-assert2assume");
help->option("-assume2assert");
help->option("-live2fair");
@ -122,6 +125,7 @@ struct ChformalPass : public Pass {
"$cover cell. If the $check cell contains a message, also produce a "
"$print cell."
);
help->close();
return true;
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override