mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Split to methods
This commit is contained in:
parent
a9b9c13591
commit
c3a6562626
1 changed files with 20 additions and 11 deletions
|
@ -51,11 +51,7 @@ class Argparse:
|
|||
self.flag_full_reverse = '--full-reverse'
|
||||
self.flag_search = '--search'
|
||||
|
||||
if (not self.configs.dialog and self.flag_search in self.args or
|
||||
not self.configs.dialog and 'configs' in self.args):
|
||||
print("Error: You should enable the dialog "
|
||||
"in the '/etc/slpkg/' folder.\n")
|
||||
self.usage.help(1)
|
||||
self.dialog_is_enabled()
|
||||
|
||||
self.options = [self.flag_yes,
|
||||
self.flag_jobs,
|
||||
|
@ -65,18 +61,31 @@ class Argparse:
|
|||
self.flag_full_reverse,
|
||||
self.flag_search]
|
||||
|
||||
# Check for correct flag
|
||||
for opt in self.args:
|
||||
if opt.startswith('--'):
|
||||
if opt not in self.options and opt not in ['--help', '--version']:
|
||||
raise SystemExit(f"\nError: flag '{opt}' does not exist.\n")
|
||||
self.check_for_flags()
|
||||
self.remove_flags()
|
||||
|
||||
# Remove flags from args
|
||||
def remove_flags(self):
|
||||
""" Remove flags from args. """
|
||||
for opt in self.options:
|
||||
if opt in self.args:
|
||||
self.args.remove(opt)
|
||||
self.flags.append(opt)
|
||||
|
||||
def dialog_is_enabled(self):
|
||||
""" Checking if the dialog box is enabled. """
|
||||
if (not self.configs.dialog and self.flag_search in self.args or
|
||||
not self.configs.dialog and 'configs' in self.args):
|
||||
print("Error: You should enable the dialog "
|
||||
"in the '/etc/slpkg/' folder.\n")
|
||||
self.usage.help(1)
|
||||
|
||||
def check_for_flags(self):
|
||||
""" Check for correct flag. """
|
||||
for opt in self.args:
|
||||
if opt.startswith('--'):
|
||||
if opt not in self.options and opt not in ['--help', '--version']:
|
||||
raise SystemExit(f"\nError: flag '{opt}' does not exist.\n")
|
||||
|
||||
def choose_packages(self, packages, method):
|
||||
""" Choose packages with dialog utility and --search flag. """
|
||||
height = 10
|
||||
|
|
Loading…
Reference in a new issue