1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 12:53:00 +00:00
kiwi-scp/src/kiwi/core.py

44 lines
1 KiB
Python
Raw Normal View History

2020-08-06 11:43:45 +00:00
import argparse
import os
###########
# CONSTANTS
KIWI_ROOT = os.getenv('KIWI_ROOT', ".")
KIWI_CONF_NAME = os.getenv('KIWI_CONF_NAME', "kiwi.yml")
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-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 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):
return getattr(self.__instance, item)