test_class.file: cli/src/test/java/com/github/olivergondza/dumpling/cli/GrepCommandTest.java
test_class.identifier: GrepCommandTest
test_class.superclass: extends AbstractCliTest
test_case.body: @Test
      public void cli() throws Exception {
          final String log = Util.asFile(Util.resource("jstack/producer-consumer.log")).getAbsolutePath();
  
          run("grep", "thread.name == 'blocked_thread'", "--in", "threaddump:" + log);
          assertThat(this, succeeded());
          assertThat(err.toString(), equalTo(String.format("Threads: 1%n")));
  
          assertThat(out.toString(), containsString("\"blocked_thread\""));
          assertThat(out.toString(), not(containsString("\"owning_thread\"")));
  
          run("grep", "false", "--in", "threaddump:" + log);
          assertThat(exitValue, equalTo(1));
          assertThat(err.toString(), equalTo(String.format("Threads: 0%n")));
  
          assertThat(out.toString(), not(containsString("\"blocked_thread\"")));
          assertThat(out.toString(), not(containsString("\"owning_thread\"")));
  
          run("grep", "--in", "threaddump:" + log);
          assertThat(exitValue, equalTo(-1));
      }
test_case.class_method_signature: GrepCommandTest.cli()
test_case.full_signature: @Test public void cli()
test_case.identifier: cli
test_case.invocations: getAbsolutePath asFile resource run assertThat succeeded assertThat toString equalTo format assertThat toString containsString assertThat toString not containsString run assertThat equalTo assertThat toString equalTo format assertThat toString not containsString assertThat toString not containsString run assertThat equalTo
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void cli()
focal_class.declarator: CONFIG = new InterpretterConfig()
focal_class.modifier: private static final
focal_class.original_string: private static final InterpretterConfig CONFIG = new InterpretterConfig();
focal_class.type: InterpretterConfig
focal_class.var_name: CONFIG
focal_class.declarator: SCRIPT_STUB = "D.runtime.threads.grep { thread -> %s }"
focal_class.modifier: private static final
focal_class.original_string: private static final String SCRIPT_STUB = "D.runtime.threads.grep { thread -> %s }";
focal_class.type: String
focal_class.var_name: SCRIPT_STUB
focal_class.declarator: runtime
focal_class.modifier: @Option(name = "-i", aliases = {"--in"}, usage = "Input for process runtime")
      private
focal_class.original_string: @Option(name = "-i", aliases = {"--in"}, usage = "Input for process runtime")
      private ProcessRuntime<?, ?, ?> runtime;
focal_class.type: ProcessRuntime<?, ?, ?>
focal_class.var_name: runtime
focal_class.declarator: porcelain = false
focal_class.modifier: @Option(name = "-p", aliases = {"--porcelain"}, usage = "Show in a format designed for machine consumption")
      private
focal_class.original_string: @Option(name = "-p", aliases = {"--porcelain"}, usage = "Show in a format designed for machine consumption")
      private boolean porcelain = false;
focal_class.type: boolean
focal_class.var_name: porcelain
focal_class.declarator: predicate
focal_class.modifier: @Argument(metaVar = "PREDICATE", usage = "Groovy expression used as a filtering criteria", required = true)
      private
focal_class.original_string: @Argument(metaVar = "PREDICATE", usage = "Groovy expression used as a filtering criteria", required = true)
      private String predicate;
focal_class.type: String
focal_class.var_name: predicate
focal_class.file: cli/src/main/java/com/github/olivergondza/dumpling/cli/GrepCommand.java
focal_class.identifier: GrepCommand
focal_class.interfaces: implements CliCommand
focal_class.class_method_signature: GrepCommand.getName()
focal_class.full_signature: @Override public String getName()
focal_class.identifier: getName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: GrepCommand.getDescription()
focal_class.full_signature: @Override public String getDescription()
focal_class.identifier: getDescription
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getDescription()
focal_class.class_method_signature: GrepCommand.run(ProcessStream process)
focal_class.full_signature: @Override public int run(ProcessStream process)
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: (ProcessStream process)
focal_class.return: int
focal_class.signature: int run(ProcessStream process)
focal_method.body: @Override
      public int run(ProcessStream process) throws CmdLineException {
          CONFIG.setupDecorateMethods();
          Binding binding = CONFIG.getDefaultBinding(process, Collections.<String>emptyList(), runtime);
          GroovyShell shell = new GroovyShell(binding, CONFIG.getCompilerConfiguration());
  
          CONFIG.setupDecorateMethods();
          String script = String.format(SCRIPT_STUB, predicate);
          ThreadSet<?, ?, ?> set = (ThreadSet<?, ?, ?>) shell.run(script, "dumpling-script", Collections.emptyList());
  
          set.toString(process.out(), porcelain ? Mode.MACHINE : Mode.HUMAN);
          process.err().printf("Threads: %d%n", set.size());
  
          return set.isEmpty() ? 1 : 0;
      }
focal_method.class_method_signature: GrepCommand.run(ProcessStream process)
focal_method.full_signature: @Override public int run(ProcessStream process)
focal_method.identifier: run
focal_method.invocations: setupDecorateMethods getDefaultBinding emptyList getCompilerConfiguration setupDecorateMethods format run emptyList toString out printf err size isEmpty
focal_method.modifiers: @Override public
focal_method.parameters: (ProcessStream process)
focal_method.return: int
focal_method.signature: int run(ProcessStream process)