Skip to content

Instantly share code, notes, and snippets.

@joshlong
Last active May 19, 2024 09:05
Show Gist options
  • Save joshlong/035a7f54658e29c256f369655178aadd to your computer and use it in GitHub Desktop.
Save joshlong/035a7f54658e29c256f369655178aadd to your computer and use it in GitHub Desktop.
this does the same thing as my existing unzip-and-open.py, but in less code and faster, with a compiler to help me.
// I'd suggest you create an alias somewhere:
// alias uao=java --enable-preview --source 21 $HOME/bin/UAO.java
// RUN: uao $HOME/Downloads/demo.zip
import java.io.*;
import java.util.function.*;
import java.util.* ;
void main(String[] args) throws Exception {
var zipFile = new File(args[0]);
var zipFileAbsolutePath = zipFile.getAbsolutePath();
var folder = new File(zipFileAbsolutePath.substring(0, zipFileAbsolutePath.lastIndexOf(".")));
new ProcessBuilder().command("unzip", "-a", zipFileAbsolutePath).inheritIO().start().waitFor();
for (var k : Set.of("build.gradle", "build.gradle.kts", "pom.xml")) {
var buildFile = new File(folder, k);
if (buildFile.exists()) {
new ProcessBuilder().command("idea", buildFile.getAbsolutePath()).inheritIO().start().waitFor();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment