Skip to content

Commit

Permalink
Cli: early curLocalShortSize
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Jan 30, 2025
1 parent ad4829e commit 937e0ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ Cli::expandOpts(const std::span<const char* const> args) const noexcept {
std::reference_wrapper<const Opts> curLocalOpts = localOpts;
const ShortOpts globalShortOpts{ globalOpts };
ShortOpts curLocalShortOpts{ localOpts };
std::size_t curMaxShortSize =
std::max(globalShortOpts.maxShortSize, curLocalShortOpts.maxShortSize);

std::vector<std::string> expanded;
for (std::size_t i = 0; i < args.size(); ++i) {
Expand All @@ -491,6 +493,9 @@ Cli::expandOpts(const std::span<const char* const> args) const noexcept {
curSubcmd = subcmds.at(arg);
curLocalOpts = subcmds.at(arg).localOpts;
curLocalShortOpts = ShortOpts{ curLocalOpts.get() };
curMaxShortSize = std::max(
globalShortOpts.maxShortSize, curLocalShortOpts.maxShortSize
);
continue;
}

Expand Down Expand Up @@ -553,10 +558,6 @@ Cli::expandOpts(const std::span<const char* const> args) const noexcept {
// "-j1" => ["-j", "1"]
// "-vvvrj1" => ["-vv", "-v", "-r", "-j", "1"]
else if (arg.starts_with("-")) {
const std::size_t curMaxShortSize = std::max(
globalShortOpts.maxShortSize, curLocalShortOpts.maxShortSize
);

bool handled = false;
std::size_t left = 1;
for (; left < arg.size(); ++left) {
Expand Down

0 comments on commit 937e0ab

Please sign in to comment.