diff --git a/src/python/jw/pkg/lib/App.py b/src/python/jw/pkg/lib/App.py index 2b3e958c..b4320df1 100644 --- a/src/python/jw/pkg/lib/App.py +++ b/src/python/jw/pkg/lib/App.py @@ -199,10 +199,6 @@ class App: # export exit_status = 0 - if not hasattr(self.__args, 'func'): - self.__parser.print_help() - return None - pr = None if self.__args.write_profile is None else cProfile.Profile() if pr is not None: pr.enable() @@ -231,8 +227,14 @@ class App: # export if exit_status: sys.exit(exit_status) - # Run sub-command. Overwrite if you want to do anything before or after + # Do the main work. Tries to run sub-commands by default. Overwrite if you + # want to do something else, for instance if you don't have sub-commands, + # or if want to do anything before and / or after the subcommands. async def _run(self, args: Namespace) -> None | int: + if not hasattr(self.__args, 'func'): + self.__parser.print_help() + return None + # Run sub-command. Overwrite if you want to do anything before or after return await self.args.func(args) def call_async(self, awaitable: Awaitable[T], timeout: float | None = None) -> T: