diff --git a/__pycache__/color_io.cpython-311.pyc b/__pycache__/color_io.cpython-311.pyc new file mode 100644 index 0000000..0c4f489 Binary files /dev/null and b/__pycache__/color_io.cpython-311.pyc differ diff --git a/color_io.py b/color_io.py new file mode 100644 index 0000000..42343bb --- /dev/null +++ b/color_io.py @@ -0,0 +1,17 @@ +import sys + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + +def input_print(p, default = ""): + eprint("\033[93m" + p, end=':\033[0m ', flush=True) + inp = input("") + if inp: + return inp + else: + if not default: + return input_print(p, default) + return default + +def green_print(p): + eprint("\033[92m" + p + "\033[0m") \ No newline at end of file diff --git a/create_site.py b/create_site.py index 99523b6..ad46b80 100644 --- a/create_site.py +++ b/create_site.py @@ -2,6 +2,7 @@ import argparse import subprocess +import color_io parser = argparse.ArgumentParser(prog='Site Generator', description='Apache/Nginx Site Generator', epilog='Currently Only For Nginx') @@ -25,21 +26,8 @@ if not install_location.endswith('/'): if not log_location.endswith('/'): log_location = log_location + "/" -def inputprint(p, default = ""): - print("\033[93m" + p, end=':\033[0m ', flush=True) - inp = input("") - if inp: - return inp - else: - if not default: - return inputprint(p, default) - return default - site = {} -site['name'] = inputprint("Enter site address (eg: 'tpgc.me')") - -def greenprint(p): - print("\033[92m" + p + "\033[0m") +site['name'] = color_io.input_print("Enter site address (eg: 'tpgc.me')") def get_config_name(): return site['name'] @@ -73,10 +61,10 @@ def write_location(f, loc, mod): f.write(" }\n\n") def create_proxy(): - greenprint("Creating proxy site") - site['location'] = inputprint("Enter site location (default '/')", "/") - site['address'] = inputprint("Enter address to proxy to (default: http://127.0.0.1)", "http://127.0.0.1") - site['port'] = inputprint("Enter port") + color_io.green_print("Creating proxy site") + site['location'] = color_io.input_print("Enter site location (default '/')", "/") + site['address'] = color_io.input_print("Enter address to proxy to (default: http://127.0.0.1)", "http://127.0.0.1") + site['port'] = color_io.input_print("Enter port") f = create_nginx() write_location(f, site['location'], ["proxy_pass " + site['address'] + ":" + site['port'], "proxy_set_header Upgrade $http_upgrade", @@ -85,8 +73,8 @@ def create_proxy(): end_nginx(f) def create_root(): - greenprint("Creating root site") - site['path'] = inputprint("Enter site files path") + color_io.green_print("Creating root site") + site['path'] = color_io.input_print("Enter site files path") f = create_nginx() f.write(" root " + site['path'] + ";\n\n"); f.write(" include php-fpm;\n\n"); diff --git a/create_systemd_service.py b/create_systemd_service.py index 50eb159..b7ce2e6 100644 --- a/create_systemd_service.py +++ b/create_systemd_service.py @@ -1,2 +1,16 @@ #!/bin/python3 +import argparse +import subprocess +import color_io + +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) + +args = parser.parse_args() + + + +if __name__ == "__main__": + \ No newline at end of file