#!/usr/bin/python3

import socket
import subprocess
from sys import stdin

from sysversion import fmt_sysversion

ENCODING = stdin.encoding  # most likely 'utf-8'


def fmt_welcome() -> str:
    welcome = "Welcome to {}".format(socket.gethostname().capitalize())

    sysversion = fmt_sysversion()
    if sysversion:
        welcome += ", " + sysversion

    return welcome


def indent(level, s) -> str:
    return "\n".join([(" " * level + line) for line in s.splitlines()])


def main():
    print(fmt_welcome())

    turnkey_sysinfo = subprocess.run(["turnkey-sysinfo"],
                                     capture_output=True, text=True).stdout
    print()
    print(indent(2, turnkey_sysinfo))
    print()


if __name__ == "__main__":
    main()
