Skip to content
This repository was archived by the owner on Sep 22, 2024. It is now read-only.

Commit 7a578e1

Browse files
committed
Fixing change_varaibles.py
1 parent 7de6aea commit 7a578e1

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

change_variables.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
"""Replace active variables with another set"""
2-
import sys
2+
from platform import system
3+
import argparse
34
import os
45

5-
def replace_env():
6+
def replace_set(set_file):
67
"""Replace Variable File"""
7-
print("Enter Set to Import: ", end='')
8-
new_env = input()
9-
10-
if "windows" in sys.platform:
11-
os.system("copy variable_sets\\" + str(new_env) + ".py user_variables.py")
8+
# Options are Darwin, Linux, Java and Windows. Java not supported
9+
if "Windows" in system():
10+
os.system("copy variable_sets\\" + str(set_file) + ".py user_variables.py")
1211
else:
13-
os.system("cp variable_sets/" + str(new_env) + ".py user_variables.py")
12+
os.system("cp variable_sets/" + str(set_file) + ".py user_variables.py")
13+
14+
def get_variable_set_file(variable_set_arg):
15+
"""Checks if the set file was provided via arg else prompt"""
16+
if variable_set_arg:
17+
return variable_set_arg
18+
return input("Enter Set to Import: ")
1419

15-
replace_env()
20+
if __name__ == '__main__':
21+
parser = argparse.ArgumentParser()
22+
parser.add_argument('--set-file', '-s')
23+
args = parser.parse_args()
24+
set_file = get_variable_set_file(args.set_file)
25+
replace_set(set_file)

0 commit comments

Comments
 (0)