Skip to content

Commit

Permalink
Rename generic command handler as bugreport
Browse files Browse the repository at this point in the history
This is the only command left in this handler.
  • Loading branch information
jemoreira committed Sep 5, 2024
1 parent 96d32be commit 08f85ca
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions base/cvd/cuttlefish/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ cc_library(
"host/commands/cvd/server_command/acloud_mixsuperimage.h",
"host/commands/cvd/server_command/acloud_translator.cpp",
"host/commands/cvd/server_command/acloud_translator.h",
"host/commands/cvd/server_command/bugreport.cpp",
"host/commands/cvd/server_command/bugreport.h",
"host/commands/cvd/server_command/clear.cpp",
"host/commands/cvd/server_command/clear.h",
"host/commands/cvd/server_command/cmd_list.cpp",
Expand All @@ -296,8 +298,6 @@ cc_library(
"host/commands/cvd/server_command/flags_collector.h",
"host/commands/cvd/server_command/fleet.cpp",
"host/commands/cvd/server_command/fleet.h",
"host/commands/cvd/server_command/generic.cpp",
"host/commands/cvd/server_command/generic.h",
"host/commands/cvd/server_command/help.cpp",
"host/commands/cvd/server_command/help.h",
"host/commands/cvd/server_command/host_tool_target.cpp",
Expand Down Expand Up @@ -412,6 +412,7 @@ cc_library(
"host/commands/cvd/server_command/acloud_common.h",
"host/commands/cvd/server_command/acloud_mixsuperimage.h",
"host/commands/cvd/server_command/acloud_translator.h",
"host/commands/cvd/server_command/bugreport.h",
"host/commands/cvd/server_command/clear.h",
"host/commands/cvd/server_command/cmd_list.h",
"host/commands/cvd/server_command/create.h",
Expand All @@ -420,7 +421,6 @@ cc_library(
"host/commands/cvd/server_command/fetch.h",
"host/commands/cvd/server_command/flags_collector.h",
"host/commands/cvd/server_command/fleet.h",
"host/commands/cvd/server_command/generic.h",
"host/commands/cvd/server_command/help.h",
"host/commands/cvd/server_command/host_tool_target.h",
"host/commands/cvd/server_command/host_tool_target_manager.h",
Expand Down
4 changes: 2 additions & 2 deletions base/cvd/cuttlefish/host/commands/cvd/request_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "host/commands/cvd/server_command/env.h"
#include "host/commands/cvd/server_command/fetch.h"
#include "host/commands/cvd/server_command/fleet.h"
#include "host/commands/cvd/server_command/generic.h"
#include "host/commands/cvd/server_command/bugreport.h"
#include "host/commands/cvd/server_command/help.h"
#include "host/commands/cvd/server_command/host_tool_target_manager.h"
#include "host/commands/cvd/server_command/lint.h"
Expand Down Expand Up @@ -81,7 +81,7 @@ RequestContext::RequestContext(
request_handlers_.emplace_back(
NewCvdClearCommandHandler(instance_manager_));
request_handlers_.emplace_back(
NewCvdGenericCommandHandler(instance_manager_));
NewCvdBugreportCommandHandler(instance_manager_));
request_handlers_.emplace_back(
NewCvdStopCommandHandler(instance_manager_, host_tool_target_manager_));
request_handlers_.emplace_back(NewCvdHelpHandler(this->request_handlers_));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "host/commands/cvd/server_command/generic.h"
#include "host/commands/cvd/server_command/bugreport.h"

#include <sys/types.h>

Expand Down Expand Up @@ -44,9 +44,9 @@ namespace {
constexpr char kSummaryHelpText[] =
"Run cvd bugreport --help for command description";

class CvdGenericCommandHandler : public CvdServerHandler {
class CvdBugreportCommandHandler : public CvdServerHandler {
public:
CvdGenericCommandHandler(InstanceManager& instance_manager);
CvdBugreportCommandHandler(InstanceManager& instance_manager);

Result<bool> CanHandle(const RequestWithStdio& request) const override;
Result<cvd::Response> Handle(const RequestWithStdio& request) override;
Expand All @@ -65,18 +65,18 @@ class CvdGenericCommandHandler : public CvdServerHandler {
static constexpr char kHostBugreportBin[] = "cvd_internal_host_bugreport";
};

CvdGenericCommandHandler::CvdGenericCommandHandler(
CvdBugreportCommandHandler::CvdBugreportCommandHandler(
InstanceManager& instance_manager)
: instance_manager_(instance_manager),
commands_{{"bugreport", "host_bugreport", "cvd_host_bugreport"}} {}

Result<bool> CvdGenericCommandHandler::CanHandle(
Result<bool> CvdBugreportCommandHandler::CanHandle(
const RequestWithStdio& request) const {
auto invocation = ParseInvocation(request.Message());
return Contains(commands_, invocation.command);
}

Result<cvd::Response> CvdGenericCommandHandler::Handle(
Result<cvd::Response> CvdBugreportCommandHandler::Handle(
const RequestWithStdio& request) {
CF_EXPECT(CanHandle(request));

Expand Down Expand Up @@ -123,7 +123,7 @@ Result<cvd::Response> CvdGenericCommandHandler::Handle(
return ResponseFromSiginfo(infop);
}

std::vector<std::string> CvdGenericCommandHandler::CmdList() const {
std::vector<std::string> CvdBugreportCommandHandler::CmdList() const {
std::vector<std::string> subcmd_list;
subcmd_list.reserve(commands_.size());
for (const auto& cmd : commands_) {
Expand All @@ -132,13 +132,13 @@ std::vector<std::string> CvdGenericCommandHandler::CmdList() const {
return subcmd_list;
}

Result<std::string> CvdGenericCommandHandler::SummaryHelp() const {
Result<std::string> CvdBugreportCommandHandler::SummaryHelp() const {
return kSummaryHelpText;
}

bool CvdGenericCommandHandler::ShouldInterceptHelp() const { return false; }
bool CvdBugreportCommandHandler::ShouldInterceptHelp() const { return false; }

Result<std::string> CvdGenericCommandHandler::DetailedHelp(
Result<std::string> CvdBugreportCommandHandler::DetailedHelp(
std::vector<std::string>& arguments) const {
static constexpr char kDetailedHelpText[] =
"Run cvd {} --help for full help text";
Expand All @@ -151,10 +151,10 @@ Result<std::string> CvdGenericCommandHandler::DetailedHelp(

} // namespace

std::unique_ptr<CvdServerHandler> NewCvdGenericCommandHandler(
std::unique_ptr<CvdServerHandler> NewCvdBugreportCommandHandler(
InstanceManager& instance_manager) {
return std::unique_ptr<CvdServerHandler>(
new CvdGenericCommandHandler(instance_manager));
new CvdBugreportCommandHandler(instance_manager));
}

} // namespace cuttlefish
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace cuttlefish {

std::unique_ptr<CvdServerHandler> NewCvdGenericCommandHandler(
std::unique_ptr<CvdServerHandler> NewCvdBugreportCommandHandler(
InstanceManager& instance_manager);

} // namespace cuttlefish

0 comments on commit 08f85ca

Please sign in to comment.