Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and add tests for console command parsing #1459

Merged
merged 17 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/Plasma/FeatureLib/pfConsoleCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ set(pfConsoleCore_SOURCES
pfConsoleCommandsCore.cpp
pfConsoleContext.cpp
pfConsoleEngine.cpp
pfConsoleParser.cpp
)

set(pfConsoleCore_HEADERS
pfConsoleCmd.h
pfConsoleContext.h
pfConsoleEngine.h
pfConsoleParser.h
)

plasma_library(pfConsoleCore SOURCES ${pfConsoleCore_SOURCES} ${pfConsoleCore_HEADERS})
Expand Down
19 changes: 19 additions & 0 deletions Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include "pfConsoleCmd.h"

#include <string_theory/format>
#include <string_theory/string_stream>

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -134,6 +135,15 @@ void pfConsoleCmdGroup::AddSubGroup( pfConsoleCmdGroup *group )
fBaseCmdGroupRef++;
}

ST::string pfConsoleCmdGroup::GetFullName()
{
if (fParentGroup == nullptr || fParentGroup == GetBaseGroup()) {
return fName;
} else {
return ST::format("{}.{}", fParentGroup->GetFullName(), fName);
}
}

//// FindCommand /////////////////////////////////////////////////////////////
// No longer recursive.

Expand Down Expand Up @@ -446,6 +456,15 @@ void pfConsoleCmd::Unlink()
*fPrevPtr = fNext;
}

ST::string pfConsoleCmd::GetFullName()
{
if (fParentGroup == pfConsoleCmdGroup::GetBaseGroup()) {
return fName;
} else {
return ST::format("{}.{}", fParentGroup->GetFullName(), fName);
}
}

//// GetSigEntry /////////////////////////////////////////////////////////////

uint8_t pfConsoleCmd::GetSigEntry(size_t i)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class pfConsoleCmdGroup

pfConsoleCmdGroup *GetNext() { return fNext; }
ST::string GetName() { return fName; }
ST::string GetFullName();
pfConsoleCmdGroup *GetParent() { return fParentGroup; }

static pfConsoleCmdGroup *GetBaseGroup();
Expand Down Expand Up @@ -262,6 +263,7 @@ class pfConsoleCmd

pfConsoleCmd *GetNext() { return fNext; }
ST::string GetName() { return fName; }
ST::string GetFullName();
ST::string GetHelp() { return fHelpString; }
ST::string GetSignature();

Expand Down
Loading