Added command clean-tmp

This commit is contained in:
Dimitris Zlatanidis 2022-06-21 22:44:54 +03:00
parent a1c7bd807a
commit 2c387c06ba
6 changed files with 29 additions and 4 deletions

View file

@ -3,6 +3,7 @@ Updated:
- Cli menu view with colors
Added:
- Unittests
- Command clean-tmp to deletes all downloaded sources from /tmp/slpkg folder
4.1.0 - 20/06/2022
Updated:

View file

@ -52,7 +52,8 @@ Usage
install <packages> Build and install the packages.
remove <packages> Remove installed packages.
search <packages> Search packages by name.
clean-logs Purge logs of dependencies.
clean-logs Clean dependencies log tracking.
clean-tmp Deletes all the downloaded sources.
OPTIONS:
--yes Answer Yes to all questions.

View file

@ -4,7 +4,7 @@
slpkg - [OPTIONS] <packages>
.SH SYNAPSES
.P
slpkg [-h|-v] [update] [build] [install] [remove] [search] [clean-logs] --yes --resolve-off --reinstall
slpkg [-h|-v] [update] [build] [install] [remove] [search] [clean-logs] [clean-tmp] --yes --resolve-off --reinstall
.SH DESCRIPTION
.P
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update.
@ -39,7 +39,12 @@ Search packages by name and view everything in your terminal.
.P
clean-logs
.RS
Purge logs of dependencies.
Cleans dependencies log tracking.
.RE
.P
clean-tmp
.RS
Deletes all the downloaded sources.
.RE
.SH OPTIONS
.P

View file

@ -8,6 +8,8 @@ from dataclasses import dataclass
from slpkg.checks import Check
from slpkg.search import Search
from slpkg.version import Version
from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.views.cli_menu import usage
from slpkg.slackbuild import Slackbuilds
from slpkg.remove_packages import RemovePackages
@ -64,6 +66,15 @@ class Argparse:
logs.clean()
raise SystemExit()
if self.args[0] == 'clean-tmp':
path = Configs.tmp_path
tmp_slpkg = Configs.tmp_slpkg
folder = Configs.prog_name
utils = Utilities()
utils.remove_folder_if_exists(path, folder)
utils.create_folder(tmp_slpkg, 'build/')
raise SystemExit()
# Update repository
if self.args[0] == 'update':
update = UpdateRepository()

View file

@ -53,3 +53,9 @@ class Utilities:
directory = f'{path}/{folder}'
if os.path.isdir(directory):
shutil.rmtree(directory)
def create_folder(self, path: str, folder: str):
''' Creates folder. '''
directory = f'{path}/{folder}'
if not os.path.isdir(directory):
os.makedirs(directory)

View file

@ -24,7 +24,8 @@ def usage(status: int):
f' {CYAN}install{ENDC} <packages> Build and install the packages.',
f' {CYAN}remove{ENDC} <packages> Remove installed packages.',
f' {CYAN}search{ENDC} <packages> Search packages by name.',
f' {CYAN}clean-logs{ENDC} Purge logs of dependencies.\n',
f' {CYAN}clean-logs{ENDC} Clean dependencies log tracking.',
f' {CYAN}clean-tmp{ENDC} Delete all the downloaded sources.\n',
f'{BOLD}OPTIONS:{ENDC}',
f' {YELLOW}--yes{ENDC} Answer Yes to all questions.',
f' {YELLOW}--jobs{ENDC} Set it for multicore systems.',