Skip to content

Commit

Permalink
command_line/options: Implemented the first part of displaying automa…
Browse files Browse the repository at this point in the history
…tic options_t help
  • Loading branch information
dragonmux committed Aug 15, 2023
1 parent a3aee63 commit 0cc6167
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions impl/command_line/options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,24 @@ namespace substrate::commandLine
}
);
}

void optionsHolder_t::displayHelp() const noexcept
{
// Figure out how much padding is needed to make everything neat
const auto padding{displayPadding() + 1U};
std::vector<optionSet_t> optionSets{};

// Now display the non-alternation options and collect option sets
console.writeln("Options:"sv);
for (const auto &option : *this)
{
std::visit(match_t
{
[=](const option_t &value) { value.displayHelp(padding); },
[&](const optionSet_t &value) { optionSets.emplace_back(value); },
}, option);
}
}
} // namespace internal
} // namespace substrate::commandLine

Expand Down
2 changes: 2 additions & 0 deletions substrate/command_line/options
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ namespace substrate::commandLine
constexpr auto end() const noexcept { return optionsIterator_t{storage, length, indexFn}; }

[[nodiscard]] size_t displayPadding() const noexcept;
void displayHelp() const noexcept;
};
}

Expand All @@ -333,6 +334,7 @@ namespace substrate::commandLine
[[nodiscard]] constexpr auto end() const noexcept { return _options.end(); }

[[nodiscard]] size_t displayPadding() const noexcept { return _options.displayPadding(); }
void displayHelp() const noexcept { _options.displayHelp(); }
};

namespace internal
Expand Down

0 comments on commit 0cc6167

Please sign in to comment.