Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85b3c70e authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Added --help option to dumpsys."

parents ee7b24f9 bbfd2b89
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -26,6 +26,17 @@ static int sort_func(const String16* lhs, const String16* rhs)
    return lhs->compare(*rhs);
}

static void usage() {
    fprintf(stderr,
        "usage: dumpsys\n"
            "         To dump all services.\n"
            "or:\n"
            "       dumpsys [--help | -l | SERVICE [ARGS]]\n"
            "         --help: shows this help\n"
            "         -l: only list services, do not dump them\n"
            "         SERVICE: dumps only service SERVICE, optionally passing ARGS to it\n");
}

int main(int argc, char* const argv[])
{
    signal(SIGPIPE, SIG_IGN);
@@ -40,9 +51,15 @@ int main(int argc, char* const argv[])
    Vector<String16> services;
    Vector<String16> args;
    bool showListOnly = false;
    if ((argc == 2) && (strcmp(argv[1], "-l") == 0)) {
    if (argc == 2) {
        if (strcmp(argv[1], "--help") == 0) {
            usage();
            return 0;
        }
        if (strcmp(argv[1], "-l") == 0) {
            showListOnly = true;
        }
    }
    if ((argc == 1) || showListOnly) {
        services = sm->listServices();
        services.sort(sort_func);