# ==================================================================================== #
#    __main__.py - This file is part of the YFrake package.                            #
# ------------------------------------------------------------------------------------ #
#                                                                                      #
#    MIT License                                                                       #
#                                                                                      #
#    Copyright (c) 2022 <NAME>                                                #
#                                                                                      #
#    Permission is hereby granted, free of charge, to any person obtaining a copy      #
#    of this software and associated documentation files (the "Software"), to deal     #
#    in the Software without restriction, including without limitation the rights      #
#    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell         #
#    copies of the Software, and to permit persons to whom the Software is             #
#    furnished to do so, subject to the following conditions:                          #
#                                                                                      #
#    The above copyright notice and this permission notice shall be included in all    #
#    copies or substantial portions of the Software.                                   #
#                                                                                      #
#    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR        #
#    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,          #
#    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE       #
#    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER            #
#    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,     #
#    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     #
#    SOFTWARE.                                                                         #
#                                                                                      #
# ==================================================================================== #
from .server.runner import server_runner
from .config.config import ConfigSingleton
from .config import utils
import asyncio


# ==================================================================================== #
if __name__ == '__main__':
    args = utils.get_runtime_args()
    run_server = args.get('run_server')
    config_file = args.get('config_file')

    if config_file == 'here':
        config_file = utils.get_cwd_config_path()
        if not config_file.exists():
            utils.copy_default_config_to(config_file)

    if run_server is True:
        config = ConfigSingleton()
        config.file = config_file
        coro = server_runner(run_forever=True)
        asyncio.run(coro)

# ==================================================================================== #
#    __main__.py - This file is part of the YFrake package.                            #
# ------------------------------------------------------------------------------------ #
#                                                                                      #
#    MIT License                                                                       #
#                                                                                      #
#    Copyright (c) 2022 <NAME>                                                #
#                                                                                      #
#    Permission is hereby granted, free of charge, to any person obtaining a copy      #
#    of this software and associated documentation files (the "Software"), to deal     #
#    in the Software without restriction, including without limitation the rights      #
#    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell         #
#    copies of the Software, and to permit persons to whom the Software is             #
#    furnished to do so, subject to the following conditions:                          #
#                                                                                      #
#    The above copyright notice and this permission notice shall be included in all    #
#    copies or substantial portions of the Software.                                   #
#                                                                                      #
#    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR        #
#    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,          #
#    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE       #
#    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER            #
#    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,     #
#    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     #
#    SOFTWARE.                                                                         #
#                                                                                      #
# ==================================================================================== #
from .server.runner import server_runner
from .config.config import ConfigSingleton
from .config import utils
import asyncio


# ==================================================================================== #
if __name__ == '__main__':
    args = utils.get_runtime_args()
    run_server = args.get('run_server')
    config_file = args.get('config_file')

    if config_file == 'here':
        config_file = utils.get_cwd_config_path()
        if not config_file.exists():
            utils.copy_default_config_to(config_file)

    if run_server is True:
        config = ConfigSingleton()
        config.file = config_file
        coro = server_runner(run_forever=True)
        asyncio.run(coro)

# ==================================================================================== # #    __main__.py - This file is part of the YFrake package.                            # # ------------------------------------------------------------------------------------ # #                                                                                      # #    MIT License                                                                       # #                                                                                      # #    Copyright (c) 2022 <NAME>                                                # #                                                                                      # #    Permission is hereby granted, free of charge, to any person obtaining a copy      # #    of this software and associated documentation files (the "Software"), to deal     # #    in the Software without restriction, including without limitation the rights      # #    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell         # #    copies of the Software, and to permit persons to whom the Software is             # #    furnished to do so, subject to the following conditions:                          # #                                                                                      # #    The above copyright notice and this permission notice shall be included in all    # #    copies or substantial portions of the Software.                                   # #                                                                                      # #    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR        # #    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,          # #    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE       # #    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER            # #    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,     # #    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE     # #    SOFTWARE.                                                                         # #                                                                                      # # ==================================================================================== # # ==================================================================================== #