summaryrefslogtreecommitdiff
path: root/cmds/lshal/DebugCommand.cpp
diff options
context:
space:
mode:
author Yifan Hong <elsk@google.com> 2017-09-08 18:00:31 -0700
committer Yifan Hong <elsk@google.com> 2017-09-14 13:40:27 -0700
commita8bedc6ae3f6d610aa634445809835c26aaf16bc (patch)
treecbfdbeef473f3073d5b7172ddc5dbd78232a38ee /cmds/lshal/DebugCommand.cpp
parentded398e5b6530c4ced5bd42f9b75ca2caa527239 (diff)
lshal: add HelpCommand
Add *Command::usage() function for each Command and let Lshal class to call them. Suppress output from getopt_long and write our own error message to customized error stream (for testing). Test: lshal_test Test: lshal --help Change-Id: I8f5847c84a3e01af29fa85871479cab3baeb5312
Diffstat (limited to 'cmds/lshal/DebugCommand.cpp')
-rw-r--r--cmds/lshal/DebugCommand.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/cmds/lshal/DebugCommand.cpp b/cmds/lshal/DebugCommand.cpp
index e657bcf4e6..d21764ce3e 100644
--- a/cmds/lshal/DebugCommand.cpp
+++ b/cmds/lshal/DebugCommand.cpp
@@ -21,9 +21,8 @@
namespace android {
namespace lshal {
-Status DebugCommand::parseArgs(const std::string &command, const Arg &arg) {
+Status DebugCommand::parseArgs(const Arg &arg) {
if (optind >= arg.argc) {
- mLshal.usage(command);
return USAGE;
}
mInterfaceName = arg.argv[optind];
@@ -34,8 +33,8 @@ Status DebugCommand::parseArgs(const std::string &command, const Arg &arg) {
return OK;
}
-Status DebugCommand::main(const std::string &command, const Arg &arg) {
- Status status = parseArgs(command, arg);
+Status DebugCommand::main(const Arg &arg) {
+ Status status = parseArgs(arg);
if (status != OK) {
return status;
}
@@ -46,6 +45,19 @@ Status DebugCommand::main(const std::string &command, const Arg &arg) {
mLshal.err());
}
+void DebugCommand::usage() const {
+
+ static const std::string debug =
+ "debug:\n"
+ " lshal debug <interface> [options [options [...]]] \n"
+ " Print debug information of a specified interface.\n"
+ " <inteface>: Format is `android.hardware.foo@1.0::IFoo/default`.\n"
+ " If instance name is missing `default` is used.\n"
+ " options: space separated options to IBase::debug.\n";
+
+ mLshal.err() << debug;
+}
+
} // namespace lshal
} // namespace android