Add more command line options

This commit is contained in:
Kirigaya Kazuto 2022-03-18 21:22:50 +00:00
parent c9ebb2c2c8
commit 1fb94e83ef

View File

@ -1,3 +1,4 @@
from ast import parse
import os import os
import sys import sys
import getopt import getopt
@ -5,7 +6,7 @@ from libwgopparser import Parser, errprint
if __name__ == "__main__": if __name__ == "__main__":
opts, args = getopt.getopt(sys.argv[1:], 'hiko:', ["tmux"]) opts, args = getopt.getopt(sys.argv[1:], 'hiko:', ["tmux", "systemd"])
opts = {p[0]: p[1] for p in opts} opts = {p[0]: p[1] for p in opts}
if '-h' in opts: if '-h' in opts:
@ -14,7 +15,8 @@ OPTIONS
-h Display this help and quit. -h Display this help and quit.
-k Output generated config to standard output -k Output generated config to standard output
-o <filename> Output generated config to file. Default is {source_filename}.gen -o <filename> Output generated config to file. Default is {source_filename}.gen
--tmux Use tmux instead of containers --tmux Use tmux mode
--systemd Use systemd mode
HELP HELP
For latest help please view https://github.com/Kiritow/wg-ops For latest help please view https://github.com/Kiritow/wg-ops
''') ''')
@ -33,6 +35,8 @@ HELP
parser.opt_source_path = filepath parser.opt_source_path = filepath
if '--tmux' in opts: if '--tmux' in opts:
parser.opt_use_tmux = True parser.opt_use_tmux = True
if '--systemd' in opts:
parser.opt_use_systemd = True
parser.parse(content) parser.parse(content)
parser.compile_interface() parser.compile_interface()