Java 类com.facebook.stetho.dumpapp.ArgsHelper 实例源码

项目:stetho    文件:CrashDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
  Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();

  String command = ArgsHelper.nextOptionalArg(argsIter, null);
  if ("throw".equals(command)) {
    doUncaughtException(argsIter);
  } else if ("kill".equals(command)) {
    doKill(dumpContext, argsIter);
  } else if ("exit".equals(command)) {
    doSystemExit(argsIter);
  } else {
    doUsage(dumpContext.getStdout());
    if (command != null) {
      throw new DumpUsageException("Unsupported command: " + command);
    }
  }
}
项目:stetho    文件:CrashDumperPlugin.java   
private void doKill(DumperContext dumpContext, Iterator<String> argsIter) throws DumpException {
  String signal = ArgsHelper.nextOptionalArg(argsIter, OPTION_KILL_DEFAULT);
  try {
    Process kill = new ProcessBuilder()
        .command("/system/bin/kill", "-" + signal, String.valueOf(android.os.Process.myPid()))
        .redirectErrorStream(true)
        .start();

    // Handle kill command output gracefully in the event that the signal delivered didn't
    // actually take out our process...
    try {
      InputStream in = kill.getInputStream();
      Util.copy(in, dumpContext.getStdout(), new byte[1024]);
    } finally {
      kill.destroy();
    }
  } catch (IOException e) {
    throw new DumpException("Failed to invoke kill: " + e);
  }
}
项目:stetho    文件:FilesDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
  Iterator<String> args = dumpContext.getArgsAsList().iterator();

  String command = ArgsHelper.nextOptionalArg(args, "");
  if ("ls".equals(command)) {
    doLs(dumpContext.getStdout());
  } else if ("tree".equals(command)) {
    doTree(dumpContext.getStdout());
  } else if ("download".equals(command)) {
    doDownload(dumpContext.getStdout(), args);
  } else {
    doUsage(dumpContext.getStdout());
    if (!"".equals(command)) {
      throw new DumpUsageException("Unknown command: " + command);
    }
  }
}
项目:stetho    文件:APODDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
  PrintStream writer = dumpContext.getStdout();
  Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();

  String command = ArgsHelper.nextOptionalArg(argsIter, null);

  if (CMD_LIST.equalsIgnoreCase(command)) {
    doList(writer);
  } else if (CMD_DELETE.equalsIgnoreCase(command)) {
    doRemove(writer, argsIter);
  } else if (CMD_CLEAR.equalsIgnoreCase(command)) {
    doClear(writer);
  } else if (CMD_REFRESH.equalsIgnoreCase(command)) {
    doRefresh(writer);
  } else {
    usage(writer);
    if (command != null) {
      throw new DumpUsageException("Unknown command: " + command);
    }
  }
}
项目:asstudydemo    文件:APODDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
    PrintStream writer = dumpContext.getStdout();
    Iterator<String> argsIter = dumpContext.getArgsAsList().iterator();

    String command = ArgsHelper.nextOptionalArg(argsIter, null);

    if (CMD_LIST.equalsIgnoreCase(command)) {
        doList(writer);
    } else if (CMD_DELETE.equalsIgnoreCase(command)) {
        doRemove(writer, argsIter);
    } else if (CMD_CLEAR.equalsIgnoreCase(command)) {
        doClear(writer);
    } else if (CMD_REFRESH.equalsIgnoreCase(command)) {
        doRefresh(writer);
    } else {
        usage(writer);
        if (command != null) {
            throw new DumpUsageException("Unknown command: " + command);
        }
    }
}
项目:sealtalk-android-master    文件:RongDbFilesDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
    Iterator<String> args = dumpContext.getArgsAsList().iterator();

    String command = ArgsHelper.nextOptionalArg(args, "");
    if ("download".equals(command)) {
        doDownload(dumpContext.getStdout(), args);
    } else {
        doUsage(dumpContext.getStdout());
        if (!"".equals(command)) {
            throw new DumpUsageException("Unknown command: " + command);
        }
    }
}
项目:sealtalk-android    文件:RongDbFilesDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
    Iterator<String> args = dumpContext.getArgsAsList().iterator();

    String command = ArgsHelper.nextOptionalArg(args, "");
    if ("download".equals(command)) {
        doDownload(dumpContext.getStdout(), args);
    } else {
        doUsage(dumpContext.getStdout());
        if (!"".equals(command)) {
            throw new DumpUsageException("Unknown command: " + command);
        }
    }
}
项目:stetho    文件:HelloWorldDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
  PrintStream writer = dumpContext.getStdout();
  Iterator<String> args = dumpContext.getArgsAsList().iterator();

  String helloToWhom = ArgsHelper.nextOptionalArg(args, null);
  if (helloToWhom != null) {
    doHello(dumpContext.getStdin(), writer, helloToWhom);
  } else {
    doUsage(writer);
  }
}
项目:asstudydemo    文件:HelloWorldDumperPlugin.java   
@Override
public void dump(DumperContext dumpContext) throws DumpException {
    PrintStream writer = dumpContext.getStdout();
    Iterator<String> args = dumpContext.getArgsAsList().iterator();

    String helloToWhom = ArgsHelper.nextOptionalArg(args, null);
    if (helloToWhom != null) {
        doHello(dumpContext.getStdin(), writer, helloToWhom);
    } else {
        doUsage(writer);
    }
}
项目:stetho    文件:CrashDumperPlugin.java   
private void doSystemExit(Iterator<String> argsIter) {
  String exitCodeStr = ArgsHelper.nextOptionalArg(argsIter, OPTION_EXIT_DEFAULT);
  System.exit(Integer.parseInt(exitCodeStr));
}
项目:stetho    文件:APODDumperPlugin.java   
private void doRemove(PrintStream writer, Iterator<String> argsIter) throws DumpUsageException {
  String rowId = ArgsHelper.nextArg(argsIter, "Expected rowId");

  delete(writer, APODContract.Columns._ID + "=?", new String[] {rowId});
}
项目:info-dumper    文件:InfoDumperPlugin.java   
@Override
public void dump(DumperContext dumperContext) throws DumpException {
    Iterator<String> argsIterator = dumperContext.getArgsAsList().iterator();

    String command = ArgsHelper.nextOptionalArg(argsIterator, null);

    mIsAll = false;

    if (CMD_BUILD_CONFIG.equalsIgnoreCase(command)) {
        dumpBuildConfig(dumperContext);
    } else if (CMD_PERMISSION.equalsIgnoreCase(command)) {
        dumpPermission(dumperContext);
    } else if (CMD_LAST_UPDATE.equalsIgnoreCase(command)) {
        dumpLastUpdate(dumperContext);
    } else if (CMD_APPLICATION_INFO.equalsIgnoreCase(command)) {
        dumpApplicationInfo(dumperContext);
    } else if (CMD_ID.equalsIgnoreCase(command)) {
        dumpIds(dumperContext);
    } else if (CMD_OS_BUILD.equalsIgnoreCase(command)) {
        dumpOsBuild(dumperContext);
    } else if (CMD_DPI.equalsIgnoreCase(command)) {
        dumpDpi(dumperContext);
    } else if (CMD_MEMORY.equalsIgnoreCase(command)) {
        dumpMemory(dumperContext);
    } else if (CMD_ERROR.equalsIgnoreCase(command)) {
        dumpError(dumperContext);
    } else if (CMD_NETWORK.equalsIgnoreCase(command)) {
        dumpNetwork(dumperContext);
    } else if (CMD_TEL.equalsIgnoreCase(command)) {
        dumpTel(dumperContext);
    } else if (CMD_ALL.equalsIgnoreCase(command)) {
        mIsAll = true;
        dumpBuildConfig(dumperContext);
        dumpPermission(dumperContext);
        dumpLastUpdate(dumperContext);
        dumpApplicationInfo(dumperContext);
        dumpIds(dumperContext);
        dumpOsBuild(dumperContext);
        dumpDpi(dumperContext);
        dumpMemory(dumperContext);
        dumpError(dumperContext);
        dumpNetwork(dumperContext);
        dumpTel(dumperContext);
    } else {
        usage(dumperContext);
        if (command != null) {
            throw new DumpUsageException("Unknown command: " + command);
        }
    }
}
项目:asstudydemo    文件:APODDumperPlugin.java   
private void doRemove(PrintStream writer, Iterator<String> argsIter) throws DumpUsageException {
    String rowId = ArgsHelper.nextArg(argsIter, "Expected rowId");

    delete(writer, APODContract.Columns._ID + "=?", new String[]{rowId});
}