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

# This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
#
# Copyright (C) 2017 Alban 'spl0k' FĂ©ron
#
# Distributed under terms of the GNU AGPLv3 license.

import sys

from supysonic.cli import SupysonicCLI
from supysonic.config import IniConfig
from supysonic.db import init_database, release_database

if __name__ == "__main__":
    config = IniConfig.from_common_locations()
    init_database(config.BASE['database_uri'])

    cli = SupysonicCLI(config)
    if len(sys.argv) > 1:
        cli.onecmd(' '.join(sys.argv[1:]))
    else:
        cli.cmdloop()

    release_database()