2019-05-12 09:24:31 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2019-04-29 06:07:40 +00:00
|
|
|
import argparse
|
2019-04-27 04:56:57 +00:00
|
|
|
|
2019-05-12 08:27:07 +00:00
|
|
|
from ungleich_dns import ungleichDNS
|
|
|
|
from ungleich_ripe import ungleichRIPE
|
2019-05-30 09:23:43 +00:00
|
|
|
from ungleich_account import Account_Create
|
2019-06-06 10:26:07 +00:00
|
|
|
from ungleich_weather import ungleichWeather
|
2019-06-08 17:10:08 +00:00
|
|
|
from ungleich_ssh_key import SSHKey
|
2019-06-12 00:57:55 +00:00
|
|
|
from ungleich_config import Ungleich_Config
|
2019-06-16 08:58:05 +00:00
|
|
|
from ungleich_vpn import ungleichVPN
|
2019-04-27 04:56:57 +00:00
|
|
|
|
2019-06-08 17:10:08 +00:00
|
|
|
VERSION = "0.0.4"
|
2019-05-12 08:09:47 +00:00
|
|
|
|
2019-06-16 08:58:05 +00:00
|
|
|
|
2019-05-12 08:09:47 +00:00
|
|
|
class ungleichCLI(object):
|
|
|
|
def __init__(self):
|
|
|
|
self._init_parser()
|
|
|
|
|
2019-05-12 08:27:07 +00:00
|
|
|
# FIXME: make it generic
|
|
|
|
dns = ungleichDNS(self.parser, self.parser_parents)
|
|
|
|
ripe = ungleichRIPE(self.parser, self.parser_parents)
|
2019-06-12 00:57:55 +00:00
|
|
|
account = Account_Create(self.parser, self.parser_parents)
|
|
|
|
config = Ungleich_Config(self.parser, self.parser_parents)
|
2019-06-08 17:10:08 +00:00
|
|
|
SSHKey(self.parser, self.parser_parents)
|
2019-06-06 10:26:07 +00:00
|
|
|
ungleichWeather(self.parser, self.parser_parents)
|
2019-06-16 08:58:05 +00:00
|
|
|
ungleichVPN(self.parser, self.parser_parents)
|
2019-05-12 08:09:47 +00:00
|
|
|
|
2019-05-12 08:27:07 +00:00
|
|
|
def _init_parser(self):
|
2019-05-12 08:09:47 +00:00
|
|
|
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()
|
2019-05-12 09:29:58 +00:00
|
|
|
if 'func' in args:
|
|
|
|
args.func(args)
|
|
|
|
else:
|
|
|
|
self.parser['main'].print_help()
|
2019-04-29 06:07:40 +00:00
|
|
|
|
|
|
|
|
2019-05-12 08:09:47 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
cli = ungleichCLI()
|
|
|
|
cli.commandline()
|