#!/usr/bin/env python3

# Copyright (C) 2020 Esteban López Rodríguez <gnu_stallman@protonmail.ch>
#
# This file is part of Spike.
#
# Spike 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.
#
# Spike 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 <https://www.gnu.org/licenses/>.

from sys import stderr
from spike.spike_pid import spike_pid
from spike.tui.tui import Tui
from spike.tg.telegram import Telegram

if __name__ == "__main__":
    pid = spike_pid()
    if not pid:
        Telegram()  # So it asks the code before Ncurses mess the terminal
        Tui()
    else:
        print("Spike is already running. PID:", pid, file=stderr)
        exit(1)
