Minor changes

This commit is contained in:
Loïc Guégan 2023-12-17 16:09:12 +08:00
parent f1e728ca24
commit 5ca0291749

View file

@ -2,31 +2,29 @@ import sys, argparse, os
from .platform import YAMLPlatformFile
from esds import __version__
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)
# Allow importlib (in simulator.run()) to import file from the platform.yaml directory
sys.path.insert(0, simulation.location)
simulation.run()
else:
parser.print_help()
def run(platform):
simulation=YAMLPlatformFile(platform)
# Allow importlib (in simulator.run()) to import file from the platform.yaml directory
sys.path.insert(0, simulation.location)
simulation.run()
def main():
##### Parse arguments
##### Main parser
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()
subparsers = parser.add_subparsers(dest="command", help='Execute the specified command')
##### Run commands
##### Run subparser
run_parser=subparsers.add_parser("run", description='Run a simulation')
run_parser=run_parser.add_argument("platform", help="Platform file")
##### Execute commands
args = parser.parse_args()
if args.command:
if args.command[0] == "run":
run(args.command)
if args.command == "run":
run(args.platform)
elif args.version:
print("ESDS v"+__version__)
else: