Updated for options

This commit is contained in:
Dimitris Zlatanidis 2023-03-21 22:27:13 +02:00
parent 2003223f50
commit 1d944aea9a
2 changed files with 29 additions and 11 deletions

View file

@ -49,6 +49,7 @@ class Argparse(Configs):
self.red: str = self.color['red']
self.endc: str = self.color['endc']
self.bred: str = f'{self.bold}{self.red}'
self.binary_repo = None
self.file_pattern: str = f'*{self.repos.repo_tag}'
@ -84,6 +85,8 @@ class Argparse(Configs):
self.flag_short_parallel: str = '-P'
self.flag_binary: str = '--binary'
self.flag_short_binary: str = '-B'
self.flag_bin_repository: str = '--repo='
self.flag_short_bin_repository: str = '-O='
self.flag_directory: str = '--directory='
self.flag_short_directory: str = '-z='
self.flag_file_pattern: str = '--file-pattern='
@ -116,6 +119,8 @@ class Argparse(Configs):
self.flag_short_parallel,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_directory,
self.flag_short_directory,
self.flag_file_pattern,
@ -133,8 +138,10 @@ class Argparse(Configs):
self.flag_short_generate,
self.flag_binary,
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
self.flag_parallel,
self.flag_short_parallel,
self.flag_short_parallel
],
'upgrade': [
self.flag_yes,
@ -150,11 +157,13 @@ class Argparse(Configs):
self.flag_file_pattern,
self.flag_short_file_pattern,
self.flag_parallel,
self.flag_short_parallel,
self.flag_short_parallel
],
'check-updates': [
self.flag_binary,
self.flag_short_binary
self.flag_short_binary,
self.flag_bin_repository,
self.flag_short_bin_repository,
],
'configs': [],
'clean-logs': [
@ -346,21 +355,29 @@ class Argparse(Configs):
"""
for arg in self.args:
if arg.startswith(self.flag_directory):
self.directory = arg.split('=')[1]
self.directory: str = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_directory
if arg.startswith(self.flag_short_directory):
self.directory = arg.split('=')[1]
self.directory: str = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_short_directory
if arg.startswith(self.flag_file_pattern):
self.file_pattern = arg.split('=')[1]
self.file_pattern: str = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_file_pattern
if arg.startswith(self.flag_short_file_pattern):
self.file_pattern = arg.split('=')[1]
self.file_pattern: str = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_short_file_pattern
if arg.startswith(self.flag_bin_repository):
self.binary_repo: str = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_bin_repository
if arg.startswith(self.flag_short_bin_repository):
self.binary_repo: str = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_short_bin_repository
def move_options(self) -> None:
""" Move options to the flags and removes from the arguments. """
new_args: list = []
@ -459,7 +476,7 @@ class Argparse(Configs):
def update(self) -> None:
if len(self.args) == 1:
update = UpdateRepository(self.flags)
update = UpdateRepository(self.flags, self.binary_repo)
update.repository()
raise SystemExit()
self.usage.help_short(1)

View file

@ -21,9 +21,10 @@ from slpkg.models.models import (Base, engine, SBoTable,
class UpdateRepository(Configs):
""" Deletes and install the data. """
def __init__(self, flags: list):
def __init__(self, flags: list, repo: str):
super(Configs, self).__init__()
self.flags: list = flags
self.repo: str = repo
self.session = Session
self.view = ViewMessage(self.flags)
@ -58,7 +59,7 @@ class UpdateRepository(Configs):
def binary_repositories(self):
""" Update the binary repositories. """
if self.repos.gnome_repo:
if self.repos.gnome_repo and self.repo == self.repos.gnome_repo_name or self.repo == '*':
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.gnome_repo_name}{self.endc}' repository, please wait...\n")
@ -78,7 +79,7 @@ class UpdateRepository(Configs):
self.data.install_gnome_data()
print()
if self.repos.conraid_repo:
if self.repos.conraid_repo and self.repo == self.repos.conraid_repo_name or self.repo == '*':
urls: list = []
print('Updating the packages list...\n')
print(f"Downloading the '{self.green}{self.repos.conraid_repo_name}{self.endc}' "