From 94fefb772713abb89331521c6c874d0fe2ef91fe Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 4 Aug 2015 01:31:51 +0300 Subject: [PATCH] Added new-config command --- man/slpkg.8 | 7 +++++++ slpkg/arguments.py | 2 ++ slpkg/main.py | 12 +++++++++++- slpkg/new_config.py | 26 +++++++++++++------------- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/man/slpkg.8 b/man/slpkg.8 index 8ebf9af1..af3f3d64 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -21,6 +21,7 @@ Usage: slpkg Commands: [repo-remove [repository]] [repo-list] [repo-info [repository]] [update [slpkg]] [health, --silent] [deps-status, --graph=[type]] + [new-config] Optional arguments: [-h] [-v] @@ -119,6 +120,12 @@ Additional options: .PP \fB--graph=[type]\fP : Drawing dependencies diagram. (example for type: ascii, image.x11, image.png etc.) +.SS new-config, manage .new configuration files +\fBslpkg\fP \fBnew-config\fP +.PP +This option searches for .new configuration files in /etc/ path and ask the user what todo with those +files. + .SH OPTIONS .PP The following arguments are available. diff --git a/slpkg/arguments.py b/slpkg/arguments.py index ad60c4c4..022d143d 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -58,6 +58,7 @@ Commands: deps-status, --graph=[type] Print dependencies status used by packages or drawing dependencies diagram. + new-config Manage .new configuration files. Optional arguments: -h, --help Print this help message and exit. @@ -135,6 +136,7 @@ def usage(repo): [repo-remove [repository]] [repo-list] [repo-info [repository]] [update [slpkg]] [health, --silent] [deps-status, --graph=[type]] + [new-config] Optional arguments: [-h] [-v] diff --git a/slpkg/main.py b/slpkg/main.py index 94b786d1..c97af02c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -36,10 +36,11 @@ from queue import QueuePkgs from repoinfo import RepoInfo from repolist import RepoList from repositories import Repo -from tracking import TrackingDeps from blacklist import BlackList from version import prog_version from health import PackageHealth +from new_config import NewConfig +from tracking import TrackingDeps from pkg_find import find_from_repos from arguments import options, usage from slpkg_update import it_self_update @@ -196,6 +197,14 @@ class ArgParse(object): else: usage("") + def command_new_config(self): + """Manage .new configuration files + """ + if len(self.args) == 1 and self.args[0] == "new-config": + NewConfig().run() + else: + usage("") + def auto_build(self): """Auto built tool """ @@ -580,6 +589,7 @@ def main(): "repo-info": argparse.command_repo_info, "health": argparse.command_health, "deps-status": argparse.command_deps_status, + "new-config": argparse.command_new_config, "-a": argparse.auto_build, "--autobuild": argparse.auto_build, "-l": argparse.pkg_list, diff --git a/slpkg/new_config.py b/slpkg/new_config.py index 7dae2343..ecaef92b 100644 --- a/slpkg/new_config.py +++ b/slpkg/new_config.py @@ -45,6 +45,19 @@ class NewConfig(object): self.etc = "/etc/" self.news = [] + def run(self): + """print .new configuration files + """ + self.find_new() + for n in self.news: + print("{0}".format(n)) + print("") + Msg().template(78) + print("| Installed {0} new configuration files:".format( + len(self.news))) + Msg().template(78) + self.choices() + def find_new(self): """Find all '.new' files from /etc/ folder and subfolders @@ -58,19 +71,6 @@ class NewConfig(object): print(" No new configuration files\n") raise SystemExit() - def view_new(self): - """print .new configuration files - """ - self.find_new() - for n in self.news: - print("{0}".format(n)) - print("") - Msg().template(78) - print("| Installed {0} new configuration files:".format( - len(self.news))) - Msg().template(78) - self.choices() - def choices(self): """Menu options for new configuration files """