Add arguments

master
grisel-davy 3 years ago
parent 3ae8a9a4f3
commit a42bc68998

@ -3,6 +3,9 @@
import subprocess
import json
import argparse
# TODO catch errors in parameters
def get_command(options):
command = 'tilix'
@ -54,17 +57,26 @@ def get_command(options):
return(command)
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:
options = json.loads(f.read())
for fen in options['fenetres']:
print(fen)
print("Lancement de {}:".format(fen['name']))
if verbose:print("Lancement de {}:".format(fen['name']))
command = get_command(fen)
print("Using command: \n{}".format(command))
if verbose:print("Using command: \n{}".format(command))
subprocess.call(command.split(' '))

Loading…
Cancel
Save