Python tooling improvements #44
|
@ -484,6 +484,17 @@ def yeet(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|
||||||
|
def prompt(msg):
|
||||||
|
while True:
|
||||||
|
answer = input(f"{msg} (y/n)> ")
|
||||||
|
if answer.lower() in ["y", "yes"]:
|
||||||
|
return True
|
||||||
|
elif answer.lower() in ["n", "no"]:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
print("Please enter \"yes\" or \"no\" and press return.")
|
||||||
|
|
||||||
|
|
||||||
def install(args):
|
def install(args):
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
dest = os.path.join(os.getenv("LOCALAPPDATA"), "orca")
|
dest = os.path.join(os.getenv("LOCALAPPDATA"), "orca")
|
||||||
|
@ -494,14 +505,8 @@ def install(args):
|
||||||
print("The Orca command-line tools will be installed to:")
|
print("The Orca command-line tools will be installed to:")
|
||||||
print(dest)
|
print(dest)
|
||||||
print()
|
print()
|
||||||
while True:
|
if not prompt("Proceed with the installation?"):
|
||||||
answer = input("Proceed with the installation? (y/n) >")
|
|
||||||
if answer.lower() in ["y", "yes"]:
|
|
||||||
break
|
|
||||||
elif answer.lower() in ["n", "no"]:
|
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
print("Please enter \"yes\" or \"no\" and press return.")
|
|
||||||
|
|
||||||
bin_dir = os.path.join(dest, "bin")
|
bin_dir = os.path.join(dest, "bin")
|
||||||
yeet(bin_dir)
|
yeet(bin_dir)
|
||||||
|
@ -526,12 +531,16 @@ def install(args):
|
||||||
|
|
||||||
print()
|
print()
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
print("The Orca tools have been installed. Make sure the Orca tools are on your PATH by")
|
print("The Orca tools have been installed to the following directory:")
|
||||||
print("adding the following path to your system PATH variable:")
|
|
||||||
print()
|
|
||||||
print(bin_dir)
|
print(bin_dir)
|
||||||
print()
|
print()
|
||||||
print("You can do this in the Windows settings by searching for \"environment variables\".")
|
print("The tools will need to be on your PATH in order to actually use them.")
|
||||||
|
if prompt("Would you like to automatically add Orca to your PATH?"):
|
||||||
|
subprocess.run(["powershell", "scripts\\updatepath.ps1", bin_dir], check=True)
|
||||||
|
print("Orca has been added to your PATH. Restart any open terminals to use it.")
|
||||||
|
else:
|
||||||
|
print("No worries. You can manually add Orca to your PATH in the Windows settings")
|
||||||
|
print("this in the Windows settings by searching for \"environment variables\".")
|
||||||
else:
|
else:
|
||||||
print("The Orca tools have been installed. Make sure the Orca tools are on your PATH by")
|
print("The Orca tools have been installed. Make sure the Orca tools are on your PATH by")
|
||||||
print("adding the following to your shell config:")
|
print("adding the following to your shell config:")
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
param (
|
||||||
|
[parameter(Mandatory=$true)]
|
||||||
|
[string]$orcaPath
|
||||||
|
)
|
||||||
|
|
||||||
|
$arrPath = [System.Environment]::GetEnvironmentVariable('PATH', 'User') -split ';'
|
||||||
|
$arrPath = $arrPath | Where-Object { $_ -ne $orcaPath } | Where-Object { $_ -ne '' }
|
||||||
|
$newPath = ($arrPath + $orcaPath) -join ';'
|
||||||
|
|
||||||
|
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
|
||||||
|
# echo $newPath
|
Loading…
Reference in New Issue