61 lines
1.9 KiB
Python
Executable file
61 lines
1.9 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
|
|
from ungleich_dns import ungleichDNS
|
|
from ungleich_ripe import ungleichRIPE
|
|
from ungleich_account import Account_Create
|
|
from ungleich_weather import ungleichWeather
|
|
from ungleich_ssh_key import SSHKey
|
|
from ungleich_config import Ungleich_Config
|
|
from ungleich_pay import ungleichPay
|
|
|
|
VERSION = "0.0.4"
|
|
|
|
class ungleichCLI(object):
|
|
def __init__(self):
|
|
self._init_parser()
|
|
|
|
# FIXME: make it generic
|
|
dns = ungleichDNS(self.parser, self.parser_parents)
|
|
ripe = ungleichRIPE(self.parser, self.parser_parents)
|
|
account = Account_Create(self.parser, self.parser_parents)
|
|
config = Ungleich_Config(self.parser, self.parser_parents)
|
|
SSHKey(self.parser, self.parser_parents)
|
|
ungleichWeather(self.parser, self.parser_parents)
|
|
ungleichPay(self.parser, self.parser_parents)
|
|
|
|
def _init_parser(self):
|
|
self.parser = {}
|
|
|
|
# Options _all_ parsers have in common
|
|
self.parser['loglevel'] = argparse.ArgumentParser(add_help=False)
|
|
self.parser['loglevel'].add_argument(
|
|
'-v', '--verbose',
|
|
action='count',
|
|
dest='verbose',
|
|
required=False)
|
|
|
|
# Main subcommand parser
|
|
self.parser['main'] = argparse.ArgumentParser(
|
|
description='ungleich-cli ' + VERSION)
|
|
self.parser['main'].add_argument(
|
|
'-V', '--version', help='Show version.', action='version',
|
|
version='%(prog)s ' + VERSION)
|
|
self.parser['sub'] = self.parser['main'].add_subparsers(
|
|
title="Commands", dest="command")
|
|
|
|
# Parents used for all parsers
|
|
self.parser_parents = self.parser['loglevel']
|
|
|
|
def commandline(self):
|
|
args = self.parser['main'].parse_args()
|
|
if 'func' in args:
|
|
args.func(args)
|
|
else:
|
|
self.parser['main'].print_help()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
cli = ungleichCLI()
|
|
cli.commandline()
|