#!/usr/bin/env python
import logging
from os.path import join, dirname
import sys
import argparse
from syncloud.app import main
from syncloud.app import logger

sys.path.append(join(dirname(__file__), '..'))

from syncloud.tools.facade import Facade


def get_arg_parser():
    parser = argparse.ArgumentParser(description='Syncloud id tool')
    parser.add_argument('--debug', action='store_true')

    subparsers = parser.add_subparsers(help='available commands', dest='action')

    subparsers.add_parser('id', help="shows id of the device")
    p = subparsers.add_parser('name', help="shows name of the device")
    p.add_argument('--text', action='store_true')

    subparsers.add_parser('footprint', help="shows footprint of the device")

    return parser

if __name__ == '__main__':
    arg_parser = get_arg_parser()
    args = arg_parser.parse_args()

    console = True if args.debug else False
    level = logging.DEBUG if args.debug else logging.INFO
    logger.init(level, console, '/tmp/syncloud-id.log')

    facade = Facade()

    main.execute(facade, args)
