2020-08-12 15:46:50 +00:00
|
|
|
# system
|
2020-08-06 11:43:45 +00:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
|
|
class Parser:
|
2020-08-10 13:21:39 +00:00
|
|
|
class __Parser:
|
|
|
|
__parser = None
|
|
|
|
__subparsers = None
|
|
|
|
__args = None
|
2020-08-06 11:43:45 +00:00
|
|
|
|
2020-08-10 13:21:39 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.__parser = argparse.ArgumentParser(description='kiwi-config')
|
2020-08-06 11:43:45 +00:00
|
|
|
|
2020-08-11 12:03:00 +00:00
|
|
|
self.__parser.add_argument(
|
|
|
|
'-v', '--verbosity',
|
|
|
|
action='count', default=0
|
|
|
|
)
|
|
|
|
|
2020-08-10 13:21:39 +00:00
|
|
|
self.__subparsers = self.__parser.add_subparsers()
|
|
|
|
self.__subparsers.required = True
|
|
|
|
self.__subparsers.dest = 'command'
|
2020-08-06 11:43:45 +00:00
|
|
|
|
2020-08-10 13:21:39 +00:00
|
|
|
def get_parser(self):
|
|
|
|
return self.__parser
|
2020-08-10 12:05:19 +00:00
|
|
|
|
2020-08-10 13:21:39 +00:00
|
|
|
def get_subparsers(self):
|
|
|
|
return self.__subparsers
|
2020-08-06 11:43:45 +00:00
|
|
|
|
2020-08-10 13:21:39 +00:00
|
|
|
def get_args(self):
|
|
|
|
if self.__args is None:
|
|
|
|
self.__args = self.__parser.parse_args()
|
2020-08-06 11:43:45 +00:00
|
|
|
|
2020-08-10 13:21:39 +00:00
|
|
|
return self.__args
|
|
|
|
|
|
|
|
__instance = None
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
if Parser.__instance is None:
|
|
|
|
Parser.__instance = Parser.__Parser()
|
|
|
|
|
|
|
|
def __getattr__(self, item):
|
2020-08-11 12:03:00 +00:00
|
|
|
return getattr(self.__instance, item)
|