0.2.1 #2

Merged
trueold89 merged 3 commits from 0.2.1 into main 2024-03-27 21:11:36 +00:00
3 changed files with 25 additions and 7 deletions
Showing only changes of commit 2280b74221 - Show all commits

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
old/ old/
VoidServiceControl/main.py
__pycache__ __pycache__
.idea .idea
.venv .venv

View File

@ -70,12 +70,10 @@ class Args(object):
""" """
Checks the arguments Checks the arguments
""" """
if len(self.__arguments) == 0: if len(self.__arguments) == 1 and self.__arguments[0] in Arg.HELP.value:
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:
raise Help() raise Help()
if len(self.__arguments) < 2:
raise TypeError(lang.errors["usage"])
if self.__arguments[0] not in Arg.all(): if self.__arguments[0] not in Arg.all():
raise TypeError(lang.errors["args"]) raise TypeError(lang.errors["args"])
@ -91,7 +89,7 @@ class Args(object):
def __iter__(self): def __iter__(self):
yield self.__action() yield self.__action()
yield self.__arguments[1] yield self.__arguments[1:]
class Service(object): class Service(object):

21
VoidServiceControl/main.py Executable file
View File

@ -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()