@Override
  public void execute(String line, PrintStream out, PrintStream err) {
    Objects.requireNonNull(classLoaderContext, "Did not set ClassLoaderCapabilities");

    CommandInvocation invocation = javaArgs.parse(line, JAVA_OPTIONS.separatorCode(' '));

    if (invocation.hasOption(RESET_CODE_ARG)) {
      code.resetCode();
    }

    if (invocation.hasOption(RESET_ALL_ARG)) {
      code.resetAll();
    }

    String codeToRun = invocation.getUnprocessedInput();
    @Nullable String className;

    if (invocation.hasOption(CLASS_ARG) && (className = extractClassName(codeToRun, err)) != null) {
      Optional<Class<Object>> javaClass =
          javacService.compileJavaClass(classLoaderContext, className, codeToRun, err);
      javaClass.ifPresent(out::println);
    } else {
      breakupJavaLines(codeToRun);

      boolean show = invocation.hasOption(SHOW_ARG);

      if (show) {
        out.println(javacService.getJavaSnippetClass(code));
        if (!codeToRun.isEmpty()) {
          // add new lines between the code and its result
          out.println();
        }
      }

      // run the current code if some input was given, or in any case when no show option
      if (!codeToRun.isEmpty() || !show) {
        runJava(out, err);
      }
    }
  }