Skip to content

Instantly share code, notes, and snippets.

@j33n
Created July 5, 2021 01:04
Show Gist options
  • Save j33n/f7fe1e419fd22f6998c1e61b8bc925a0 to your computer and use it in GitHub Desktop.
Save j33n/f7fe1e419fd22f6998c1e61b8bc925a0 to your computer and use it in GitHub Desktop.
Spring Initializer Unzip, Open, and Delete(start.spring.io)
#!/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))
extension = ".zip"
folder = zipFile[:-len(extension)] if zipFile.endswith(extension) else zipFile
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