summaryrefslogtreecommitdiff
path: root/simpleperf/main.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-06-01 11:21:37 -0700
committerYabin Cui <yabinc@google.com>2015-06-04 15:26:32 -0700
commitf79f07e13c56f7ca3be1435cea7f8861daf7efaa (patch)
tree8c76bac6fe4d9b52b69e57393f5deecb18febd97 /simpleperf/main.cpp
parentd4637d6e7d17f48d9325fa133be82b06a408f523 (diff)
downloadextras-f79f07e13c56f7ca3be1435cea7f8861daf7efaa.tar.gz
Simpleperf: refactor command system.
Register a callback function to create a new command instance instead of registering a command instance. Then we can release resources in the command destructors, and don't need xxxCommandImpl classes any more. Bug: 19483574 Change-Id: Ibb54892ec0655fd43909347afd72bb08bc8a716c
Diffstat (limited to 'simpleperf/main.cpp')
-rw-r--r--simpleperf/main.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/simpleperf/main.cpp b/simpleperf/main.cpp
index 173026eb..93c52e50 100644
--- a/simpleperf/main.cpp
+++ b/simpleperf/main.cpp
@@ -38,12 +38,13 @@ int main(int argc, char** argv) {
}
}
- Command* command = Command::FindCommandByName(args[0]);
+ std::unique_ptr<Command> command = CreateCommandInstance(args[0]);
if (command == nullptr) {
LOG(ERROR) << "malformed command line: unknown command " << args[0];
return 1;
}
std::string command_name = args[0];
+ args.erase(args.begin());
LOG(DEBUG) << "command '" << command_name << "' starts running";
bool result = command->Run(args);