From 84b455ae1b74d82ae3badf0683ccc5e74cd1721d Mon Sep 17 00:00:00 2001 From: Rudolph Pienaar Date: Mon, 29 Apr 2024 11:16:10 -0400 Subject: [PATCH] Add logic for module handling --- spleenseg/splparser.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spleenseg/splparser.py b/spleenseg/splparser.py index c27fb4a..0a69877 100644 --- a/spleenseg/splparser.py +++ b/spleenseg/splparser.py @@ -98,11 +98,21 @@ def parser_setup(str_desc): return parser -def parser_interpret(parser, *args): +def parser_interpret(parser, *args, **kwargs): """ Interpret the list space of *args, or sys.argv[1:] if *args is empty """ + asModule: bool = False + for k, v in kwargs.items(): + if k == "asModule": + asModule = v + if asModule: + # Here, spleenseg is used a module to another app + # and the CLI sys.argv is that of the parent app + # not spleenseg. Interpret the passwd parser and + # return. + return parser.parse_args() if len(args): args = parser.parse_args(*args) else: