Add arguments
This commit is contained in:
parent
3ae8a9a4f3
commit
a42bc68998
1 changed files with 18 additions and 6 deletions
24
jumpstart.py
24
jumpstart.py
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
# TODO catch errors in parameters
|
||||||
|
|
||||||
def get_command(options):
|
def get_command(options):
|
||||||
command = 'tilix'
|
command = 'tilix'
|
||||||
|
@ -54,17 +57,26 @@ def get_command(options):
|
||||||
return(command)
|
return(command)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
templates_dir = './templates/'
|
|
||||||
params_path = './params.json'
|
|
||||||
|
|
||||||
template = 'eet2.json'
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("template",help="Specify the templato to use (must be in ./templates).")
|
||||||
|
parser.add_argument("-t","--templates_dir", help="Specify the template directory (absolute path)")
|
||||||
|
parser.add_argument("-p","--parameters", help="Specify the parameters file (default to ./params.json)")
|
||||||
|
parser.add_argument("-v", "--verbose", help="Activate verbose output", action="store_true")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
templates_dir = args.templates_dir or "./templates/"
|
||||||
|
params_path = args.parameters or "./params.json"
|
||||||
|
|
||||||
|
template = args.template + ".json"
|
||||||
|
verbose = args.verbose
|
||||||
|
|
||||||
with open(templates_dir+template,'r') as f:
|
with open(templates_dir+template,'r') as f:
|
||||||
options = json.loads(f.read())
|
options = json.loads(f.read())
|
||||||
|
|
||||||
for fen in options['fenetres']:
|
for fen in options['fenetres']:
|
||||||
print(fen)
|
if verbose:print("Lancement de {}:".format(fen['name']))
|
||||||
print("Lancement de {}:".format(fen['name']))
|
|
||||||
command = get_command(fen)
|
command = get_command(fen)
|
||||||
print("Using command: \n{}".format(command))
|
if verbose:print("Using command: \n{}".format(command))
|
||||||
subprocess.call(command.split(' '))
|
subprocess.call(command.split(' '))
|
||||||
|
|
Loading…
Reference in a new issue