from __future__ import absolute_import
from nilmdb.printf import *

from argparse import ArgumentDefaultsHelpFormatter as def_form

def setup(self, sub):
    cmd = sub.add_parser("info", help="Server information",
                         formatter_class = def_form,
                         description="""
                         List information about the server, like
                         version.
                         """)
    cmd.set_defaults(handler = cmd_info)

def cmd_info(self):
    """Print info about the server"""
    printf("Client library version: %s\n", self.client.client_version)
    printf("Server version: %s\n", self.client.version())
    printf("Server URL: %s\n", self.client.geturl())
    printf("Server database path: %s\n", self.client.dbpath())
    printf("Server database size: %s\n", self.client.dbsize())
