Inspired by John Long's uao script.
Created
January 20, 2019 15:33
-
-
Save fuzzylimes/d45268c99fde3e8a1933b9bc1ac4faf2 to your computer and use it in GitHub Desktop.
Spring Initializer Unzip, Open, and Delete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import os | |
import subprocess | |
def execute(command): | |
print('Running: {}'.format(command)) | |
return subprocess.check_call(command, shell=True) | |
if __name__ == '__main__': | |
assert len(sys.argv) == 2 and sys.argv[1].endswith('.zip'), 'Must supply a single zip file to unpackage.' | |
fileName = sys.argv[1] | |
zipFile = os.path.abspath(sys.argv[1]) | |
assert os.path.exists(zipFile), 'Provided file does not exist.' | |
try: | |
execute('unzip -a "{}"'.format(zipFile)) | |
except: | |
sys.exit("Error while unzipping {}. Exiting.".format(fileName)) | |
folder = zipFile.split('.')[0] | |
pom = os.path.join(folder, 'pom.xml') | |
try: | |
execute('open -a /Applications/IntelliJ\ IDEA\ CE.app/ "{}"'.format(pom)) | |
except: | |
sys.exit("Unable to open pom file.") | |
print("Deleting {}".format(zipFile)) | |
os.remove(zipFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment