kiwi-scp/src/kiwi/core.py

43 lines
970 B
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:
__parser = None
2020-08-06 11:43:45 +00:00
__subparsers = None
__args = None
@classmethod
def get_parser(cls):
if cls.__parser is None:
cls.__parser = argparse.ArgumentParser(description='kiwi-config')
2020-08-06 11:43:45 +00:00
cls.__parser.add_argument(
2020-08-10 12:39:28 +00:00
'-v', '--verbosity',
action='count', default=0
)
2020-08-06 11:43:45 +00:00
return cls.__parser
2020-08-06 11:43:45 +00:00
@classmethod
def get_subparsers(cls):
if cls.__subparsers is None:
cls.__subparsers = cls.get_parser().add_subparsers()
cls.__subparsers.required = True
cls.__subparsers.dest = 'command'
2020-08-06 11:43:45 +00:00
return cls.__subparsers
@classmethod
def get_args(cls):
if cls.__args is None:
cls.__args = cls.get_parser().parse_args()
2020-08-06 11:43:45 +00:00
return cls.__args