summaryrefslogtreecommitdiff
path: root/esds/__main__.py
blob: 35637c14c2e56ddc7ed2d2de2574fe4ee8deae34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys, argparse, os
from esds.helpers.platform import YAMLPlatformFile
from esds import __version__

# Allow importlib to import file from current working directory
sys.path.insert(0, os.getcwd())

def run(arguments):
    parser = argparse.ArgumentParser(description='Run a simulation')
    parser.add_argument("platform", help="Run a simulation using a specific platform file")
    args = parser.parse_args(arguments[1:])
    if args.platform:
        simulation=YAMLPlatformFile(args.platform)
        simulation.run()
    else:
        parser.print_help()

def main():
    ##### Parse arguments
    parser = argparse.ArgumentParser(
        description='ESDS simulator command line interface. Run simulations and perform various simulation tasks.',
        formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("command", help="Execute the specified command.\nAvailable commands are: run", nargs=argparse.REMAINDER)
    parser.add_argument("--version", help="Show esds version", action="store_true")
    args = parser.parse_args()

    ##### Run commands
    if args.command:
        if args.command[0] == "run":
            run(args.command)
    elif args.version:
        print("ESDS v"+__version__)
    else:
        parser.print_help()