Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 063a80a

Browse files
committed
clang-tidy readability fix
1 parent 9a89fbd commit 063a80a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

include/cli/cli.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ namespace cli
206206
{
207207
if (!enabled) return {};
208208
if (name.rfind(line, 0) == 0) return {name}; // name starts_with line
209-
else return {};
209+
return {};
210210
}
211211
protected:
212212
const std::string& Name() const { return name; }
@@ -244,7 +244,7 @@ namespace cli
244244
{
245245
public:
246246
CliSession(Cli& _cli, std::ostream& _out, std::size_t historySize = 100);
247-
virtual ~CliSession() { cli.UnRegister(out); }
247+
virtual ~CliSession() { Cli::UnRegister(out); }
248248

249249
// disable value semantics
250250
CliSession(const CliSession&) = delete;
@@ -419,11 +419,12 @@ namespace cli
419419

420420
bool ScanCmds(const std::vector<std::string>& cmdLine, CliSession& session)
421421
{
422-
if (!IsEnabled()) return false;
422+
if (!IsEnabled())
423+
return false;
423424
for (auto& cmd: *cmds)
424-
if (cmd->Exec(cmdLine, session)) return true;
425-
if (parent && parent->Exec(cmdLine, session)) return true;
426-
return false;
425+
if (cmd->Exec(cmdLine, session))
426+
return true;
427+
return (parent && parent->Exec(cmdLine, session));
427428
}
428429

429430
std::string Prompt() const
@@ -436,7 +437,8 @@ namespace cli
436437
if (!IsEnabled()) return;
437438
for (const auto& cmd: *cmds)
438439
cmd->Help(out);
439-
if (parent) parent->Help(out);
440+
if (parent != nullptr)
441+
parent->Help(out);
440442
}
441443

442444
void Help(std::ostream& out) const override
@@ -452,7 +454,7 @@ namespace cli
452454
std::vector<std::string> GetCompletions(const std::string& currentLine) const
453455
{
454456
auto result = cli::GetCompletions(cmds, currentLine);
455-
if (parent)
457+
if (parent != nullptr)
456458
{
457459
auto c = parent->GetCompletionRecursive(currentLine);
458460
result.insert(result.end(), std::make_move_iterator(c.begin()), std::make_move_iterator(c.end()));
@@ -677,7 +679,7 @@ namespace cli
677679
{
678680
history.LoadCommands(cli.GetCommands());
679681

680-
cli.Register(out);
682+
Cli::Register(out);
681683
globalScopeMenu->Insert(
682684
"help",
683685
[this](std::ostream&){ Help(); },
@@ -727,8 +729,6 @@ namespace cli
727729
<< cmd
728730
<< "\"\n";
729731
}
730-
731-
return;
732732
}
733733

734734
inline void CliSession::Prompt()

0 commit comments

Comments
 (0)