From cd81c583d31d2b41b3d9ef0d82f8dfedd34b6432 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Wed, 17 Apr 2024 18:26:03 -0400 Subject: [PATCH] files --- create_systemd_service.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/create_systemd_service.py b/create_systemd_service.py index b7ce2e6..250b269 100644 --- a/create_systemd_service.py +++ b/create_systemd_service.py @@ -3,14 +3,30 @@ import argparse import subprocess import color_io +import sys parser = argparse.ArgumentParser(prog='SystemD Service Generator', description='SystemD Service Unit File Generator', epilog='Meow') parser.add_argument("-i", "--install", nargs='?', const="/etc/systemd/system/", default=None) +parser.add_argument("service_name", required=("--install" in sys.argv or "-i" in sys.argv), default=None) args = parser.parse_args() +f = sys.stdout +if args.install: + path = args.install + if not args.install.endswith("/"): + path += "/" + path += args.service_name + if not args.service_name.endswith(".service"): + path += ".service" + f = open(path, "wt") + +def bprint(*args, **kwargs): + print(*args, file=f, **kwargs) if __name__ == "__main__": - \ No newline at end of file + bprint("[Unit]") + description = color_io.input_print("Please enter description: ") + bprint("") \ No newline at end of file