class InstallPackage extends AbstractCommand {

  @Override
  public void execute() throws Exception {
    assertTrue(0 < arguments.size() && arguments.size() < 3);
    final String packageName = getArgument(0);
    logger.debug("URL: {}", packageName);
    final int separatorIndex = packageName.indexOf("/");
    assertTrue(0 < separatorIndex, "Invalid argument: " + packageName);
    final Optional<String> checkout = getOptionalArgument(1);

    final CloneGit cloneGit = new CloneGit();
    logger.trace("CloneGit: {}", cloneGit);
    cloneGit.setArguments(asList(packageName, checkout.orElse("master")));
    cloneGit.execute();
    final FileSet fileSet = cloneGit.getFileSet();
    logger.debug("FileSet: {}", fileSet.getFiles());

    final String publishRepository = append(System.getProperty("user.home"), MODULES_BASE);
    final Path publishPath = Paths.get(append(publishRepository, packageName));
    if (exists(publishPath)) {
      deleteRecursively(publishPath, ALLOW_INSECURE);
    }
    createDirectories(publishPath);
    fileSet.copyTo(publishPath);
    printer.println(bind(NL_0, packageName));
    printer.println(bind(NL_1, publishPath));
  }

}