mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Added border color
This commit is contained in:
parent
abc0f0f50f
commit
34e503314f
4 changed files with 48 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
4.8.4 - 14/05/2023
|
||||
Added:
|
||||
- Case-insensitive pattern matching, --no-case option
|
||||
- Choose border color via configuration file
|
||||
|
||||
4.8.3 - 29/04/2023
|
||||
Updated:
|
||||
|
|
|
@ -55,6 +55,12 @@ PROGRESS_SPINNER = "pixel"
|
|||
# Default is green. [green/violet/yellow/blue/cyan/grey/red]
|
||||
SPINNER_COLOR = "green"
|
||||
|
||||
# Choose color for the border box.
|
||||
# Bold colors: [bold_green/bold_cyan/bold_yellow/bold_red/bold_blue]
|
||||
# Colors: [green/cyan/yellow/red/blue]
|
||||
# Default is bold_green.
|
||||
BORDER_COLOR = "bold_green"
|
||||
|
||||
# Enable or disable case-sensitive pattern matching.
|
||||
# Default is true. [true/false]
|
||||
CASE_SENSITIVE = true
|
||||
|
|
|
@ -46,6 +46,7 @@ class Configs:
|
|||
spinning_bar: str = True
|
||||
progress_spinner: str = 'pixel'
|
||||
spinner_color: str = 'green'
|
||||
border_color: str = 'bgreen'
|
||||
case_sensitive: bool = True
|
||||
|
||||
proxy_address: str = str()
|
||||
|
@ -83,6 +84,7 @@ class Configs:
|
|||
spinning_bar: str = config['SPINNING_BAR']
|
||||
progress_spinner: str = config['PROGRESS_SPINNER']
|
||||
spinner_color: str = config['SPINNER_COLOR']
|
||||
border_color: str = config['BORDER_COLOR']
|
||||
case_sensitive: bool = config['CASE_SENSITIVE']
|
||||
proxy_address: str = config['PROXY_ADDRESS']
|
||||
proxy_username: str = config['PROXY_USERNAME']
|
||||
|
@ -100,7 +102,9 @@ class Configs:
|
|||
yellow: str = str()
|
||||
byellow: str = str()
|
||||
cyan: str = str()
|
||||
bcyan: str = str()
|
||||
blue: str = str()
|
||||
bblue: str = str()
|
||||
grey: str = str()
|
||||
violet: str = str()
|
||||
endc: str = str()
|
||||
|
@ -115,7 +119,9 @@ class Configs:
|
|||
yellow: str = '\x1b[93m'
|
||||
byellow: str = f'{bold}{yellow}'
|
||||
cyan: str = '\x1b[96m'
|
||||
blue: str = '\x1b[94m'
|
||||
bcyan: str = f'{bold}{cyan}'
|
||||
blue: str = f'\x1b[94m'
|
||||
bblue: str = f'{bold}{blue}'
|
||||
grey: str = '\x1b[38;5;247m'
|
||||
violet: str = '\x1b[35m'
|
||||
endc: str = '\x1b[0m'
|
||||
|
|
|
@ -19,6 +19,10 @@ class AsciiBox(Configs):
|
|||
if self.package_alignment < 1:
|
||||
self.package_alignment = 1
|
||||
|
||||
self.bd_color: str = self.endc
|
||||
self.border_colors: dict = {}
|
||||
self.assign_border_color()
|
||||
|
||||
self.bullet: str = '-'
|
||||
self.done: str = 'Done'
|
||||
self.vertical_line: str = '|'
|
||||
|
@ -48,38 +52,57 @@ class AsciiBox(Configs):
|
|||
self.vertical_and_right: str = '├'
|
||||
self.vertical_and_left: str = '┤'
|
||||
|
||||
def assign_border_color(self):
|
||||
self.border_colors: dict[str] = {
|
||||
'bold_yellow': self.byellow,
|
||||
'bold_green': self.bgreen,
|
||||
'bold_cyan': self.bcyan,
|
||||
'bold_blue': self.bblue,
|
||||
'bold_red': self.bred,
|
||||
'yellow': self.yellow,
|
||||
'green': self.green,
|
||||
'cyan': self.cyan,
|
||||
'blue': self.blue,
|
||||
'red': self.red,
|
||||
'': self.endc
|
||||
}
|
||||
try:
|
||||
self.bd_color: str = self.border_colors[self.border_color]
|
||||
except KeyError:
|
||||
self.bd_color: str = self.endc
|
||||
|
||||
def draw_package_title(self, message: str, title: str) -> None:
|
||||
title = title.title()
|
||||
print(f"{self.bgreen}{self.upper_left_corner}{self.horizontal_line * (self.columns - 2)}"
|
||||
print(f"{self.bd_color}{self.upper_left_corner}{self.horizontal_line * (self.columns - 2)}"
|
||||
f"{self.upper_right_corner}")
|
||||
print(f"{self.vertical_line}{title.center(self.columns - 2, ' ')}{self.vertical_line}")
|
||||
self.draw_middle_line()
|
||||
print(f"{self.vertical_line} {self.endc}{message.ljust(self.columns - 3, ' ')}"
|
||||
f"{self.bgreen}{self.vertical_line}")
|
||||
f"{self.bd_color}{self.vertical_line}")
|
||||
self.draw_middle_line()
|
||||
print(f"{self.bgreen}{self.vertical_line}{self.endc} {'Package:':<{self.package_alignment}}"
|
||||
print(f"{self.bd_color}{self.vertical_line}{self.endc} {'Package:':<{self.package_alignment}}"
|
||||
f"{'Version:':<{self.version_alignment}}{'Size:':<{self.size_alignment}}{'Repo:':>{self.repo_alignment}} "
|
||||
f"{self.bgreen}{self.vertical_line}{self.endc}")
|
||||
f"{self.bd_color}{self.vertical_line}{self.endc}")
|
||||
|
||||
def draw_package_line(self, package: str, version: str, size: str, color: str, repo: str) -> None:
|
||||
if len(version) >= 20 and self.columns <= 80:
|
||||
version: str = f'{version[:self.version_alignment - 5]}...'
|
||||
if len(package) >= 15 and self.columns <= 80:
|
||||
package: str = f'{package[:self.package_alignment - 5]}...'
|
||||
print(f"{self.bgreen}{self.vertical_line} {self.bold}{color}{package:<{self.package_alignment}}{self.endc}"
|
||||
f"{self.bgreen}{version:<{self.version_alignment}}{self.endc}{size:<{self.size_alignment}}{self.blue}"
|
||||
f"{repo:>{self.repo_alignment}}{self.bgreen} {self.vertical_line}{self.endc}")
|
||||
print(f"{self.bd_color}{self.vertical_line} {self.bold}{color}{package:<{self.package_alignment}}{self.endc}"
|
||||
f"{self.bd_color}{version:<{self.version_alignment}}{self.endc}{size:<{self.size_alignment}}{self.blue}"
|
||||
f"{repo:>{self.repo_alignment}}{self.bd_color} {self.vertical_line}{self.endc}")
|
||||
|
||||
def draw_middle_line(self) -> None:
|
||||
print(f"{self.bgreen}{self.vertical_and_right}{self.horizontal_line * (self.columns - 2)}"
|
||||
print(f"{self.bd_color}{self.vertical_and_right}{self.horizontal_line * (self.columns - 2)}"
|
||||
f"{self.vertical_and_left}")
|
||||
|
||||
def draw_dependency_line(self) -> None:
|
||||
print(f"{self.bgreen}{self.vertical_line}{self.endc} Dependencies:{' ' * (self.columns - 16)}"
|
||||
f"{self.bgreen}{self.vertical_line}{self.endc}")
|
||||
print(f"{self.bd_color}{self.vertical_line}{self.endc} Dependencies:{' ' * (self.columns - 16)}"
|
||||
f"{self.bd_color}{self.vertical_line}{self.endc}")
|
||||
|
||||
def draw_bottom_line(self) -> None:
|
||||
print(f"{self.bgreen}{self.lower_left_corner}{self.horizontal_line * (self.columns - 2)}"
|
||||
print(f"{self.bd_color}{self.lower_left_corner}{self.horizontal_line * (self.columns - 2)}"
|
||||
f"{self.lower_right_corner}{self.endc}")
|
||||
|
||||
def draw_checksum_error_box(self, name: str, checksum: str, file_check: str) -> None:
|
||||
|
|
Loading…
Reference in a new issue