mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-06 08:46:21 +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
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import difflib
|
import difflib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -8,26 +9,41 @@ from pathlib import Path
|
||||||
|
|
||||||
class NewConfig:
|
class NewConfig:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, options: list):
|
||||||
|
self.options: list = options
|
||||||
self.etc_path: str = '/etc/slpkg'
|
self.etc_path: str = '/etc/slpkg'
|
||||||
self.slpkg_config = Path(self.etc_path, 'slpkg.toml')
|
self.slpkg_config = Path(self.etc_path, 'slpkg.toml')
|
||||||
self.blacklist_config = Path(self.etc_path, 'blacklist.toml')
|
self.blacklist_config = Path(self.etc_path, 'blacklist.toml')
|
||||||
self.slpkg_config_new = Path(self.etc_path, 'slpkg.toml.new')
|
self.slpkg_config_new = Path(self.etc_path, 'slpkg.toml.new')
|
||||||
self.blacklist_config_new = Path(self.etc_path, 'blacklist.toml.new')
|
self.blacklist_config_new = Path(self.etc_path, 'blacklist.toml.new')
|
||||||
|
|
||||||
color = {
|
if '--no-colors' in self.options:
|
||||||
'bold': '\033[1m',
|
color = {
|
||||||
'red': '\x1b[91m',
|
'bold': '',
|
||||||
'green': '\x1b[32m',
|
'red': '',
|
||||||
'yellow': '\x1b[93m',
|
'green': '',
|
||||||
'cyan': '\x1b[96m',
|
'yellow': '',
|
||||||
'blue': '\x1b[94m',
|
'cyan': '',
|
||||||
'grey': '\x1b[38;5;247m',
|
'blue': '',
|
||||||
'violet': '\x1b[35m',
|
'grey': '',
|
||||||
'endc': '\x1b[0m'
|
'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.bold: str = color['bold']
|
||||||
|
self.red: str = color['red']
|
||||||
self.green: str = color['green']
|
self.green: str = color['green']
|
||||||
self.yellow: str = color['yellow']
|
self.yellow: str = color['yellow']
|
||||||
self.bgreen: str = f'{color["bold"]}{color["green"]}'
|
self.bgreen: str = f'{color["bold"]}{color["green"]}'
|
||||||
|
@ -121,13 +137,13 @@ class NewConfig:
|
||||||
""" Remove slpkg.toml.new file. """
|
""" Remove slpkg.toml.new file. """
|
||||||
if self.slpkg_config_new.is_file():
|
if self.slpkg_config_new.is_file():
|
||||||
self.slpkg_config_new.unlink()
|
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):
|
def remove_blacklist_file(self):
|
||||||
""" Remove blacklist.toml.new file. """
|
""" Remove blacklist.toml.new file. """
|
||||||
if self.blacklist_config_new.is_file():
|
if self.blacklist_config_new.is_file():
|
||||||
self.blacklist_config_new.unlink()
|
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):
|
def prompt(self):
|
||||||
""" Prompt K, O, R selection for every single file. """
|
""" Prompt K, O, R selection for every single file. """
|
||||||
|
@ -183,5 +199,13 @@ class NewConfig:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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()
|
config.check()
|
||||||
|
|
Loading…
Add table
Reference in a new issue