mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-05 08:46:20 +01:00
Updated for help
This commit is contained in:
parent
19c7eefe7d
commit
df9596abd2
1 changed files with 39 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import shutil
|
||||
import difflib
|
||||
from pathlib import Path
|
||||
|
@ -8,26 +9,41 @@ from pathlib import Path
|
|||
|
||||
class NewConfig:
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, options: list):
|
||||
self.options: list = options
|
||||
self.etc_path: str = '/etc/slpkg'
|
||||
self.slpkg_config = Path(self.etc_path, 'slpkg.toml')
|
||||
self.blacklist_config = Path(self.etc_path, 'blacklist.toml')
|
||||
self.slpkg_config_new = Path(self.etc_path, 'slpkg.toml.new')
|
||||
self.blacklist_config_new = Path(self.etc_path, 'blacklist.toml.new')
|
||||
|
||||
color = {
|
||||
'bold': '\033[1m',
|
||||
'red': '\x1b[91m',
|
||||
'green': '\x1b[32m',
|
||||
'yellow': '\x1b[93m',
|
||||
'cyan': '\x1b[96m',
|
||||
'blue': '\x1b[94m',
|
||||
'grey': '\x1b[38;5;247m',
|
||||
'violet': '\x1b[35m',
|
||||
'endc': '\x1b[0m'
|
||||
}
|
||||
if '--no-colors' in self.options:
|
||||
color = {
|
||||
'bold': '',
|
||||
'red': '',
|
||||
'green': '',
|
||||
'yellow': '',
|
||||
'cyan': '',
|
||||
'blue': '',
|
||||
'grey': '',
|
||||
'violet': '',
|
||||
'endc': ''
|
||||
}
|
||||
else:
|
||||
color = {
|
||||
'bold': '\033[1m',
|
||||
'red': '\x1b[91m',
|
||||
'green': '\x1b[32m',
|
||||
'yellow': '\x1b[93m',
|
||||
'cyan': '\x1b[96m',
|
||||
'blue': '\x1b[94m',
|
||||
'grey': '\x1b[38;5;247m',
|
||||
'violet': '\x1b[35m',
|
||||
'endc': '\x1b[0m'
|
||||
}
|
||||
|
||||
self.bold: str = color['bold']
|
||||
self.red: str = color['red']
|
||||
self.green: str = color['green']
|
||||
self.yellow: str = color['yellow']
|
||||
self.bgreen: str = f'{color["bold"]}{color["green"]}'
|
||||
|
@ -121,13 +137,13 @@ class NewConfig:
|
|||
""" Remove slpkg.toml.new file. """
|
||||
if self.slpkg_config_new.is_file():
|
||||
self.slpkg_config_new.unlink()
|
||||
print(f"rm {self.slpkg_config_new}")
|
||||
print(f"rm {self.red}{self.slpkg_config_new}{self.endc}")
|
||||
|
||||
def remove_blacklist_file(self):
|
||||
""" Remove blacklist.toml.new file. """
|
||||
if self.blacklist_config_new.is_file():
|
||||
self.blacklist_config_new.unlink()
|
||||
print(f"rm {self.blacklist_config_new}")
|
||||
print(f"rm {self.red}{self.blacklist_config_new}{self.endc}")
|
||||
|
||||
def prompt(self):
|
||||
""" Prompt K, O, R selection for every single file. """
|
||||
|
@ -183,5 +199,13 @@ class NewConfig:
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
config = NewConfig()
|
||||
args = sys.argv
|
||||
args.pop(0)
|
||||
if '--help' in args or '-h' in args:
|
||||
print('slpkg_new-configs [OPTIONS]\n'
|
||||
'\n--no-colors Disable the output colors.\n'
|
||||
'-h, --help Show this message and exit.\n')
|
||||
sys.exit()
|
||||
|
||||
config = NewConfig(args)
|
||||
config.check()
|
||||
|
|
Loading…
Add table
Reference in a new issue