diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/Documentation_Manual.h b/Plugins/UEWingman/Source/UEWingman/Handlers/Documentation_Manual.h index 3e3dbe3c..c3a431c8 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/Documentation_Manual.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/Documentation_Manual.h @@ -12,16 +12,19 @@ class UWing_Documentation_Manual : public UWingHandler GENERATED_BODY() public: - UPROPERTY(EditAnywhere, meta=(Optional, Description="If specified, print only this section of the manual")) + UPROPERTY(EditAnywhere, meta=(Optional, Description="section of the manual")) FString Section; virtual void Register() override { - UWingServer::AddHandler(this, - TEXT("Print the user manual.")); + TStringBuilder<128> Docs; + Docs.Append(TEXT("Print a section of the manual. Valid sections: ")); + WingManual::PrintSectionNames(nullptr, WingManual::GetSections(), Docs); + UWingServer::AddHandler(this, Docs.ToString()); } virtual void Handle() override { + TSet Sections = WingManual::GetSections(); if (Section.IsEmpty()) { UWingManualSections::FetcherPaths(); @@ -34,10 +37,15 @@ public: else { FName SectionName(*Section); - if (!WingManual::PrintSection(SectionName)) + if (WingManual::PrintSection(SectionName)) { - WingOut::Stdout.Printf(TEXT("ERROR: Unknown manual section '%s'\nAvailable sections: "), *Section); - WingManual::PrintSectionNames(WingManual::GetSections()); + WingOut::Stdout.Printf(TEXT("\n")); + WingManual::PrintSectionNames(TEXT("Other manual sections:"), Sections, WingOut::Stdout); + } + else + { + WingOut::Stdout.Printf(TEXT("Unknown manual section '%s'\n")); + WingManual::PrintSectionNames(TEXT("Valid manual sections:"), Sections, WingOut::Stdout); } } } diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingManual.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingManual.cpp index abdc3e09..d3b663fc 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingManual.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingManual.cpp @@ -185,9 +185,6 @@ void UWingManualSections::ImportantCommands() "\n You can use Documentation_Commands(Query=Command,Verbose=true)" "\n to get detailed help for a specific command." "\n" - "\n You can use Documentation_Manual(Section=Name) to print out" - "\n a specific manual section." - "\n" )); } @@ -201,17 +198,18 @@ TSet WingManual::GetSections() return Result; } -void WingManual::PrintSectionNames(const TSet& Sections) +void WingManual::PrintSectionNames(const TCHAR *Prefix, const TSet& Sections, WingOut Output) { if (Sections.IsEmpty()) return; + if (Prefix) Output.Print(Prefix); bool bFirst = true; for (const FName& Section : Sections) { if (!bFirst) WingOut::Stdout.Print(TEXT(", ")); bFirst = false; - WingOut::Stdout.Printf(TEXT("%s"), *Section.ToString()); + Output.Printf(TEXT("%s"), *Section.ToString()); } - WingOut::Stdout.Print(TEXT("\n")); + if (Prefix) Output.Print(TEXT("\n")); } bool WingManual::PrintSection(FName Section) diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingServer.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingServer.cpp index e54f794f..02060f1c 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingServer.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingServer.cpp @@ -187,14 +187,18 @@ FString UWingServer::HandleRequest(const FString& Line) WingOut::Stdout.Printf(TEXT("UE_LOG: %s\n"), *Msg); } LogCapture.CapturedErrors.Empty(); - if (bSuggestHandlerHelp && LastHandler) + if (bSuggestHandlerHelp || (!SuggestedManualSections.IsEmpty())) { - WingManual::PrintHandlerHelp(*LastHandler); - } - if (!SuggestedManualSections.IsEmpty()) - { - WingOut::Stdout.Print(TEXT("Suggested manual sections: ")); - WingManual::PrintSectionNames(SuggestedManualSections); + if (LastHandler) WingManual::PrintHandlerHelp(*LastHandler); + if ((LastHandler == nullptr) || (LastHandler->Name != TEXT("Documentation_Manual"))) + { + WingOut::Stdout.Print(TEXT("To see manual: command=Documentation_Manual\n")); + } + if (!SuggestedManualSections.IsEmpty()) + { + WingManual::PrintSectionNames(TEXT("Suggested manual sections: "), + SuggestedManualSections, WingOut::Stdout); + } } FString Result = WingOut::StdoutBuffer.ToString(); WingOut::StdoutBuffer.Reset(); @@ -231,7 +235,7 @@ void UWingServer::TryCallHandler(const FString &Line) FWingHandlerConfig* Found = FindHandler(Command); if (!Found) { - WingOut::Stdout.Printf(TEXT("Unknown command: %s"), *Command); + WingOut::Stdout.Printf(TEXT("Unknown command: %s\n"), *Command); UWingServer::SuggestManual(GET_FUNCTION_NAME_CHECKED(UWingManualSections, ImportantCommands)); return; } diff --git a/Plugins/UEWingman/Source/UEWingman/Public/WingManual.h b/Plugins/UEWingman/Source/UEWingman/Public/WingManual.h index 26dfed5a..90a56cfa 100644 --- a/Plugins/UEWingman/Source/UEWingman/Public/WingManual.h +++ b/Plugins/UEWingman/Source/UEWingman/Public/WingManual.h @@ -1,5 +1,6 @@ #pragma once #include "CoreMinimal.h" +#include "WingBasics.h" #include "WingManual.generated.h" struct FWingHandlerConfig; @@ -15,7 +16,7 @@ public: static void Commands(EWingHandlerKind Kind, const FString& Query, bool Verbose); static TSet GetSections(); static bool PrintSection(FName Section); - static void PrintSectionNames(const TSet& Sections); + static void PrintSectionNames(const TCHAR *Prefix, const TSet& Sections, WingOut Output); }; UCLASS()