#!/usr/bin/env python3
# This file is placed in the Public Domain.
# pylint: disable=C0413,W0105,W0611


"cli"


import getpass
import sys


from otpcr.command import Commands, command
from otpcr.runtime import NAME, Client, Event


"defines"


TXT = """[Unit]
Description=%s
After=network-online.target

[Service]
Type=simple
User=%s
Group=%s
ExecStart=/home/%s/.local/bin/%ss

[Install]
WantedBy=multi-user.target"""


"client"


class CLI(Client):

    "CLI"

    def raw(self, txt):
        "print text."
        print(txt)


def srv(event):
    "create service file (pipx)."
    name  = getpass.getuser()
    event.reply(TXT % (NAME.upper(), name, name, name, NAME))


Commands.add(srv)


"main"


from otpcr.modules import face


def main():
    "main"
    cli = CLI()
    evt = Event()
    evt.txt = " ".join(sys.argv[1:])
    command(cli, evt)
    evt.wait()


if __name__ == "__main__":
    main()
