diff --git a/bin/slpkg_new-configs b/bin/slpkg_new-configs new file mode 100755 index 00000000..864f9f45 --- /dev/null +++ b/bin/slpkg_new-configs @@ -0,0 +1,10 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +from slpkg.new_configs import main + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + raise SystemExit(1) diff --git a/slpkg/new_config.py b/slpkg/new_configs.py similarity index 92% rename from slpkg/new_config.py rename to slpkg/new_configs.py index d18cbbc3..8a9b52b4 100644 --- a/slpkg/new_config.py +++ b/slpkg/new_configs.py @@ -1,13 +1,14 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +import sys import shutil import difflib import subprocess from pathlib import Path -class NewConfig: +class NewConfigs: def __init__(self, options: list): __slots__ = 'options' @@ -255,3 +256,34 @@ class NewConfig: output = subprocess.call(f'vimdiff {file1} {file2}', shell=True) if output != 0: raise SystemExit(output) + + +def main(): + args = sys.argv + args.pop(0) + + options: list = [ + '--no-colors', + '-h', '--help' + ] + + if len(args) == 1: + if options[1] in args or options[2] 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() + elif args[0] == options[0]: + pass + else: + print('\ntry: slpkg_new-configs --help\n') + sys.exit(1) + elif len(args) > 1: + print('\ntry: slpkg_new-configs --help\n') + sys.exit(1) + + try: + config = NewConfigs(args) + config.check() + except KeyboardInterrupt: + raise SystemExit(1) diff --git a/slpkg/toml_error_message.py b/slpkg/toml_error_message.py index acdc7d3e..8c97ea7a 100644 --- a/slpkg/toml_error_message.py +++ b/slpkg/toml_error_message.py @@ -12,4 +12,4 @@ class TomlErrors: raise SystemExit(f"\n{self.tool_name}: Error: {error}: in the configuration\n" f"file '{toml_file}', edit the file and check for errors,\n" f"or if you have upgraded the '{self.tool_name}' maybe you need to run:\n" - f"\n $ slpkg new-config\n") + f"\n $ slpkg_new-config\n") diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 8b7c3252..99305d4e 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -26,11 +26,10 @@ class Usage(Configs): args: str = ( f'Usage: {self.prog_name} [{self.cyan}COMMAND{self.endc}] [{self.yellow}OPTIONS{self.endc}] ' f'[FILELIST|PACKAGES...]\n' - f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates]\n' - f' slpkg [{self.cyan}COMMAND{self.endc}] [-I, repo-info, -L, clean-logs, -T, clean-data]\n' - f' slpkg [{self.cyan}COMMAND{self.endc}] [-D, clean-tmp, -g, configs, -x, new-config]\n' - f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download [packages...]]\n' - f' slpkg [{self.cyan}COMMAND{self.endc}] [-R, remove, -f, find, -w, view [packages...]]\n' + f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates, -I, repo-info]\n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-g, configs, -L, clean-logs, -T, clean-data, -D, clean-tmp]\n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -R, remove [packages...]]\n' + f' slpkg [{self.cyan}COMMAND{self.endc}] [-d, download, -f, find, -w, view [packages...]]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-s, search, -e, dependees, -t, tracking [packages...]]\n' f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall]\n' f' slpkg [{self.yellow}OPTIONS{self.endc}] [-k, --skip-installed, -E, --full-reverse, -S, --search]\n' @@ -54,14 +53,13 @@ class Usage(Configs): f' {self.cyan}-c, check-updates{self.endc} Check for news on ChangeLog.txt.\n' f' {self.cyan}-I, repo-info{self.endc} Prints the repositories information.\n' f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n' - f' {self.cyan}-x, new-config{self.endc} Search for new configuration files.\n' f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n' f' {self.cyan}-T, clean-data{self.endc} Clean all the repositories data.\n' f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n' f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n' f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n' - f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n' f' {self.cyan}-R, remove{self.endc} [packages...] Remove installed packages.\n' + f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n' f' {self.cyan}-f, find{self.endc} [packages...] Find installed packages.\n' f' {self.cyan}-w, view{self.endc} [packages...] View packages from the repository.\n' f' {self.cyan}-s, search{self.endc} [packages...] Search packages from the repository.\n'