You can now manage multiple services && main.py is now indexed in the repository
This commit is contained in:
parent
2280b74221
commit
ae747ca569
|
@ -1,5 +1,4 @@
|
|||
old/
|
||||
VoidServiceControl/main.py
|
||||
__pycache__
|
||||
.idea
|
||||
.venv
|
||||
|
|
|
@ -70,12 +70,10 @@ class Args(object):
|
|||
"""
|
||||
Checks the arguments
|
||||
"""
|
||||
if len(self.__arguments) == 0:
|
||||
raise TypeError(lang.errors["usage"])
|
||||
if len(self.__arguments) != 2 and self.__arguments[0] not in Arg.HELP.value:
|
||||
raise TypeError(lang.errors["usage"])
|
||||
if self.__arguments[0] in Arg.HELP.value:
|
||||
if len(self.__arguments) == 1 and self.__arguments[0] in Arg.HELP.value:
|
||||
raise Help()
|
||||
if len(self.__arguments) < 2:
|
||||
raise TypeError(lang.errors["usage"])
|
||||
if self.__arguments[0] not in Arg.all():
|
||||
raise TypeError(lang.errors["args"])
|
||||
|
||||
|
@ -91,7 +89,7 @@ class Args(object):
|
|||
|
||||
def __iter__(self):
|
||||
yield self.__action()
|
||||
yield self.__arguments[1]
|
||||
yield self.__arguments[1:]
|
||||
|
||||
|
||||
class Service(object):
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from VoidServiceControl.classes import Su, Interface, Args, Help
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
Su()
|
||||
action, services = tuple(Args())
|
||||
for service_name in services:
|
||||
service = Interface(service_name)
|
||||
service.action(action)
|
||||
del service
|
||||
except TypeError as e:
|
||||
print(f"{e}\n\n{Help()}")
|
||||
except (ValueError, PermissionError, Help) as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue