diff --git a/cores/microwatt/microwatt/__main__.py b/cores/microwatt/microwatt/__main__.py index a5be109..b59d63c 100644 --- a/cores/microwatt/microwatt/__main__.py +++ b/cores/microwatt/microwatt/__main__.py @@ -11,4 +11,4 @@ class MicrowattSession(PowerFVSession, core_cls=MicrowattCore): if __name__ == "__main__": PROG = "python -m {}".format(PurePath(__file__).parent.name) - MicrowattSession(prog=PROG).main() + MicrowattSession().main(prog=PROG) diff --git a/power_fv/session.py b/power_fv/session.py index 7ffe153..c60d495 100644 --- a/power_fv/session.py +++ b/power_fv/session.py @@ -17,17 +17,11 @@ __all__ = ["PowerFVSession"] class PowerFVCommandExit(Exception): pass -class PowerFVCommandError(Exception): - pass - class _ArgumentParser(argparse.ArgumentParser): def exit(self, status=0, message=None): raise PowerFVCommandExit() - def error(self, message): - raise PowerFVCommandError() - class PowerFVSession: def __init_subclass__(cls, *, core_cls, **kwargs): @@ -38,7 +32,7 @@ class PowerFVSession: cls.core_cls = core_cls def __init__(self, prog=None): - self.parser = _ArgumentParser(prog=prog, add_help=False) + self.parser = _ArgumentParser(prog="", add_help=False) self.subparsers = self.parser.add_subparsers(help="commands") self._checks = dict() @@ -47,8 +41,8 @@ class PowerFVSession: self.add_dump_subparser() self.add_build_subparser() - def main(self): - parser = argparse.ArgumentParser(prog=self.parser.prog) + def main(self, prog): + parser = argparse.ArgumentParser(prog=prog) group = parser.add_mutually_exclusive_group() group.add_argument( "-i", dest="interact", action="store_true", @@ -86,8 +80,6 @@ class PowerFVSession: cmd(**vars(args)) except PowerFVCommandExit: pass - except PowerFVCommandError: - self.help() # Subparsers