#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright © 2013 Miguel González <migonzalvar@activitycentral.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

import argparse

import xs_authserver


def runserver():
    xs_authserver.app.run(host='0.0.0.0', port=5000, debug=True)


def init_db():
    xs_authserver.init_db()


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="xs-authserver command utility")
    parser.add_argument('command', choices=['runserver', 'initdb'])
    args = parser.parse_args()
    if args.command == 'runserver':
        runserver()
    elif args.command == 'initdb':
        init_db()
