mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Updated for help
This commit is contained in:
parent
4319ea82a6
commit
7000139f9f
2 changed files with 30 additions and 27 deletions
|
@ -53,7 +53,7 @@ class Argparse(Configs):
|
||||||
self.file_pattern = self.file_pattern_conf
|
self.file_pattern = self.file_pattern_conf
|
||||||
|
|
||||||
if len(self.args) == 0 or '' in self.args:
|
if len(self.args) == 0 or '' in self.args:
|
||||||
self.usage.help_short()
|
self.usage.help_short(1)
|
||||||
|
|
||||||
self.check.is_blacklist(self.args)
|
self.check.is_blacklist(self.args)
|
||||||
|
|
||||||
|
@ -285,10 +285,13 @@ class Argparse(Configs):
|
||||||
self.usage.help_minimal()
|
self.usage.help_minimal()
|
||||||
|
|
||||||
# Fixed for correct options by command.
|
# Fixed for correct options by command.
|
||||||
options = self.commands[self.args[0]]
|
try:
|
||||||
for opt in self.flags:
|
options = self.commands[self.args[0]]
|
||||||
if opt not in options:
|
for opt in self.flags:
|
||||||
invalid.append(opt)
|
if opt not in options:
|
||||||
|
invalid.append(opt)
|
||||||
|
except (KeyError, IndexError):
|
||||||
|
self.usage.help_short(1)
|
||||||
|
|
||||||
# Prints error for invalid options.
|
# Prints error for invalid options.
|
||||||
if invalid:
|
if invalid:
|
||||||
|
@ -421,21 +424,21 @@ class Argparse(Configs):
|
||||||
def help(self) -> None:
|
def help(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
self.usage.help(0)
|
self.usage.help(0)
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def version(self) -> None:
|
def version(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
version = Version()
|
version = Version()
|
||||||
version.view()
|
version.view()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
update = UpdateRepository(self.flags)
|
update = UpdateRepository(self.flags)
|
||||||
update.repository()
|
update.repository()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def upgrade(self) -> None:
|
def upgrade(self) -> None:
|
||||||
command = Argparse.upgrade.__name__
|
command = Argparse.upgrade.__name__
|
||||||
|
@ -455,7 +458,7 @@ class Argparse(Configs):
|
||||||
install = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
|
install = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
|
||||||
install.execute()
|
install.execute()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def check_updates(self) -> None:
|
def check_updates(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
|
@ -463,13 +466,13 @@ class Argparse(Configs):
|
||||||
check = CheckUpdates()
|
check = CheckUpdates()
|
||||||
check.updates()
|
check.updates()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def edit_configs(self) -> None:
|
def edit_configs(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
self.form_configs.edit()
|
self.form_configs.edit()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def clean_logs(self) -> None:
|
def clean_logs(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
|
@ -478,7 +481,7 @@ class Argparse(Configs):
|
||||||
logs = CleanLogsDependencies(self.flags)
|
logs = CleanLogsDependencies(self.flags)
|
||||||
logs.clean()
|
logs.clean()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def clean_tmp(self) -> None:
|
def clean_tmp(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
|
@ -495,14 +498,14 @@ class Argparse(Configs):
|
||||||
print(f"The folder '{self.tmp_path}{self.prog_name}' was cleaned!")
|
print(f"The folder '{self.tmp_path}{self.prog_name}' was cleaned!")
|
||||||
|
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def clean_data(self) -> None:
|
def clean_data(self) -> None:
|
||||||
if len(self.args) == 1:
|
if len(self.args) == 1:
|
||||||
update = UpdateRepository(self.flags)
|
update = UpdateRepository(self.flags)
|
||||||
update.drop_the_tables()
|
update.drop_the_tables()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def build(self) -> None:
|
def build(self) -> None:
|
||||||
command = Argparse.build.__name__
|
command = Argparse.build.__name__
|
||||||
|
@ -521,7 +524,7 @@ class Argparse(Configs):
|
||||||
build = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
|
build = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
|
||||||
build.execute()
|
build.execute()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def install(self) -> None:
|
def install(self) -> None:
|
||||||
command = Argparse.install.__name__
|
command = Argparse.install.__name__
|
||||||
|
@ -540,7 +543,7 @@ class Argparse(Configs):
|
||||||
install = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
|
install = Slackbuilds(packages, self.flags, self.file_pattern, mode=command)
|
||||||
install.execute()
|
install.execute()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def download(self) -> None:
|
def download(self) -> None:
|
||||||
command = Argparse.download.__name__
|
command = Argparse.download.__name__
|
||||||
|
@ -557,7 +560,7 @@ class Argparse(Configs):
|
||||||
download = Download(self.directory, self.flags)
|
download = Download(self.directory, self.flags)
|
||||||
download.packages(packages)
|
download.packages(packages)
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def remove(self) -> None:
|
def remove(self) -> None:
|
||||||
command = Argparse.remove.__name__
|
command = Argparse.remove.__name__
|
||||||
|
@ -575,7 +578,7 @@ class Argparse(Configs):
|
||||||
remove = RemovePackages(packages, self.flags, self.file_pattern)
|
remove = RemovePackages(packages, self.flags, self.file_pattern)
|
||||||
remove.remove()
|
remove.remove()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def find(self) -> None:
|
def find(self) -> None:
|
||||||
command = Argparse.find.__name__
|
command = Argparse.find.__name__
|
||||||
|
@ -592,7 +595,7 @@ class Argparse(Configs):
|
||||||
find = FindInstalled()
|
find = FindInstalled()
|
||||||
find.find(packages, self.file_pattern)
|
find.find(packages, self.file_pattern)
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def view(self) -> None:
|
def view(self) -> None:
|
||||||
command = Argparse.view.__name__
|
command = Argparse.view.__name__
|
||||||
|
@ -610,7 +613,7 @@ class Argparse(Configs):
|
||||||
view = ViewPackage(self.flags)
|
view = ViewPackage(self.flags)
|
||||||
view.package(packages)
|
view.package(packages)
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def search(self) -> None:
|
def search(self) -> None:
|
||||||
command = Argparse.search.__name__
|
command = Argparse.search.__name__
|
||||||
|
@ -627,7 +630,7 @@ class Argparse(Configs):
|
||||||
search = SearchPackage()
|
search = SearchPackage()
|
||||||
search.package(packages)
|
search.package(packages)
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def dependees(self) -> None:
|
def dependees(self) -> None:
|
||||||
command = Argparse.dependees.__name__
|
command = Argparse.dependees.__name__
|
||||||
|
@ -645,7 +648,7 @@ class Argparse(Configs):
|
||||||
dependees = Dependees(packages, self.flags)
|
dependees = Dependees(packages, self.flags)
|
||||||
dependees.slackbuilds()
|
dependees.slackbuilds()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def tracking(self) -> None:
|
def tracking(self) -> None:
|
||||||
command = Argparse.tracking.__name__
|
command = Argparse.tracking.__name__
|
||||||
|
@ -663,7 +666,7 @@ class Argparse(Configs):
|
||||||
tracking = Tracking(self.flags)
|
tracking = Tracking(self.flags)
|
||||||
tracking.packages(packages)
|
tracking.packages(packages)
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
def help_for_commands(self) -> None:
|
def help_for_commands(self) -> None:
|
||||||
""" Extra help information for commands. """
|
""" Extra help information for commands. """
|
||||||
|
@ -671,7 +674,7 @@ class Argparse(Configs):
|
||||||
flags = self.commands[self.args[1]]
|
flags = self.commands[self.args[1]]
|
||||||
Help(self.args[1], flags).view()
|
Help(self.args[1], flags).view()
|
||||||
else:
|
else:
|
||||||
self.usage.help_short()
|
self.usage.help_short(1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -724,7 +727,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
arguments[args[0]]()
|
arguments[args[0]]()
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
usage.help_short()
|
usage.help_short(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Usage(Configs):
|
||||||
print(args)
|
print(args)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
def help_short(self) -> NoReturn:
|
def help_short(self, status: int) -> NoReturn:
|
||||||
""" Prints the short menu. """
|
""" Prints the short menu. """
|
||||||
args = (
|
args = (
|
||||||
f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] '
|
f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] '
|
||||||
|
@ -45,7 +45,7 @@ class Usage(Configs):
|
||||||
" \nIf you need more information please try 'slpkg --help'.")
|
" \nIf you need more information please try 'slpkg --help'.")
|
||||||
|
|
||||||
print(args)
|
print(args)
|
||||||
raise SystemExit()
|
raise SystemExit(status)
|
||||||
|
|
||||||
def help(self, status: int) -> NoReturn:
|
def help(self, status: int) -> NoReturn:
|
||||||
""" Prints the main menu. """
|
""" Prints the main menu. """
|
||||||
|
|
Loading…
Reference in a new issue