Start of simulation application
This commit is contained in:
31
src/bedit_gui/simulation_application.py
Normal file
31
src/bedit_gui/simulation_application.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(exit_on_error=False)
|
||||
|
||||
parser.add_argument(
|
||||
"-f", "--file", type=str, help="Path to a BEditor BEsim file to open", default=None, required=False
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--component", type=str, help="Component path in BEdit file to simulate", default=None, required=False
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--simulation", type=str, help="Simulation name in BEdit file to simulate", default=None, required=False
|
||||
)
|
||||
|
||||
return parser.parse_args(), parser
|
||||
|
||||
def main() -> int:
|
||||
try:
|
||||
args, parser = parse_arguments()
|
||||
# TODO check if file is a BEditor file (.beb or .json)
|
||||
if args.file and not (args.component or args.simulation):
|
||||
parser.error("Component or Simulation required when opening a BEdit file")
|
||||
except argparse.ArgumentError as e:
|
||||
print(e.message)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
Reference in New Issue
Block a user