add cli skeleton
This commit is contained in:
parent
0f9f4a7142
commit
4f14fb406a
|
@ -1,29 +1,103 @@
|
|||
|
||||
import logging
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
|
||||
def cmd_foo(args, parser):
|
||||
class BackupdbClient(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
def cmd_list_configured(args, parser):
|
||||
"""
|
||||
If there is a config file, list backups configured in it
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cmd_bar(args, parser):
|
||||
def cmd_list_namespace(args, parser):
|
||||
"""
|
||||
List namespaces
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cmd_list_backup(args, parser):
|
||||
"""
|
||||
List backups in a namespace
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cmd_list_dates(args, parser):
|
||||
"""
|
||||
List available dates for a backup
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cmd_backup(args, parser):
|
||||
"""
|
||||
Create a new backup - requires it be defined in the config file
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cmd_download(args, parser):
|
||||
"""
|
||||
Download a backup
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def cmd_restore(args, parser):
|
||||
"""
|
||||
Restore a backup
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-c", "--config", help="config file path")
|
||||
parser.add_argument("-s", "--server", help="server address")
|
||||
|
||||
sp_action = parser.add_subparsers(dest="action", help="action to take")
|
||||
|
||||
p_foo = sp_action.add_parser("foo", help="foo action")
|
||||
p_foo.set_defaults(func=cmd_foo)
|
||||
p_foo.add_argument("-c", "--config", help="config file path")
|
||||
p_list = sp_action.add_parser("list", help="list action")
|
||||
sp_list = p_list.add_subparsers(dest="list_action", help="item to list", required=True)
|
||||
|
||||
sp_bar = sp_action.add_subparsers(dest="bar", help="bar action")
|
||||
sp_bar.set_defaults(func=cmd_bar)
|
||||
sp_bar.add_argument("-s", "--shutdown", action="store_true", help="shutdown on program exit")
|
||||
p_list_configured = sp_list.add_parser("configured", help="list locally configured backups")
|
||||
p_list_configured.set_defaults(func=cmd_list_configured)
|
||||
|
||||
p_list_namespace = sp_list.add_parser("namespace", help="list namespaces")
|
||||
p_list_namespace.set_defaults(func=cmd_list_namespace)
|
||||
|
||||
p_list_backup = sp_list.add_parser("backup", help="list backups")
|
||||
p_list_backup.set_defaults(func=cmd_list_backup)
|
||||
p_list_backup.add_argument("-n", "--namespace", default="default", help="parent namespace to list in")
|
||||
|
||||
p_list_dates = sp_list.add_parser("date", help="list dates")
|
||||
p_list_dates.set_defaults(func=cmd_list_dates)
|
||||
p_list_dates.add_argument("-n", "--namespace", default="default", help="parent namespace to list in")
|
||||
p_list_dates.add_argument("backup", help="backup to list dates for")
|
||||
|
||||
p_backup = sp_action.add_parser("backup", help="backup action")
|
||||
p_backup.set_defaults(func=cmd_backup)
|
||||
p_backup.add_argument("-n", "--namespace", default="default", help="parent namespace backup to")
|
||||
p_backup.add_argument("backup", help="backup to make")
|
||||
|
||||
p_download = sp_action.add_parser("download", help="download action")
|
||||
p_download.set_defaults(func=cmd_download)
|
||||
p_download.add_argument("-n", "--namespace", default="default", help="parent namespace download from")
|
||||
p_download.add_argument("backup", help="backup to download")
|
||||
p_download.add_argument("date", help="date of backup to download")
|
||||
|
||||
p_restore = sp_action.add_parser("restore", help="restore action")
|
||||
p_restore.set_defaults(func=cmd_restore)
|
||||
p_restore.add_argument("-n", "--namespace", default="default", help="parent namespace download from")
|
||||
p_restore.add_argument("backup", help="backup to download")
|
||||
p_restore.add_argument("date", help="date of backup to download")
|
||||
|
||||
return parser.parse_args(), parser
|
||||
|
||||
|
@ -31,4 +105,9 @@ def get_args():
|
|||
def main():
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
args, parser = get_args()
|
||||
|
||||
#TODO one of `config` or `server` or a default config file is required
|
||||
|
||||
client = BackupdbClient()
|
||||
|
||||
args.func(args, parser)
|
||||
|
|
Loading…
Reference in New Issue