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

44 lines
969 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(
'-v', '--verbose',
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