Improve reusability of --dump-inputs output (#6812)

This commit is contained in:
Geza Lore
2025-12-16 11:08:19 +00:00
committed by GitHub
parent 25f72e4305
commit 47a4f7fb9b
31 changed files with 685 additions and 361 deletions
+15 -6
View File
@@ -39,14 +39,23 @@ struct V3OptionParser::Impl final {
// Base class of actual action classes
template <en N_Mode, bool N_Allow_Partial_Match = false>
class ActionBase VL_NOT_FINAL : public ActionIfs {
bool m_notForRerun = false; // This option is not needed for rerun with --dump-inputs
bool m_undocumented = false; // This option is not documented
public:
bool isValueNeeded() const override final { return N_Mode == en::VALUE; }
bool isFOnOffAllowed() const override final { return N_Mode == en::FONOFF; }
bool isNotForRerun() const override final { return m_notForRerun; }
bool isOnOffAllowed() const override final { return N_Mode == en::ONOFF; }
bool isPartialMatchAllowed() const override final { return N_Allow_Partial_Match; }
bool isUndocumented() const override { return m_undocumented; }
void undocumented() override { m_undocumented = true; }
ActionIfs& undocumented() override {
m_undocumented = true;
return *this;
}
ActionIfs& notForRerun() override {
m_notForRerun = true;
return *this;
}
};
// Actual action classes
@@ -195,20 +204,20 @@ bool V3OptionParser::hasPrefixNo(const char* strp) {
return VString::startsWith(strp, "-no");
}
int V3OptionParser::parse(int idx, int argc, char* argv[]) {
std::pair<int, bool> V3OptionParser::parse(int idx, int argc, char* argv[]) {
UASSERT(m_pimpl->m_isFinalized, "finalize() must be called before parse()");
const char* optp = argv[idx];
if (optp[0] == '-' && optp[1] == '-') ++optp;
ActionIfs* const actp = find(optp);
if (!actp) return 0;
if (!actp) return {0, false};
if (!actp->isValueNeeded()) {
actp->exec(optp, nullptr);
return 1;
return {1, !actp->isNotForRerun()};
} else if (idx + 1 < argc) {
actp->exec(optp, argv[idx + 1]);
return 2;
return {2, !actp->isNotForRerun()};
}
return 0;
return {0, false};
}
string V3OptionParser::getSuggestion(const char* str) const {