mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Add editor via configuration file
This commit is contained in:
parent
8a90961fb1
commit
83a15cdf01
8 changed files with 25 additions and 18 deletions
|
@ -300,7 +300,7 @@ For Slackware 'current' users must change the variable VERSION in '/etc/slpkg/sl
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ slpkg -g edit=nano
|
||||
$ slpkg -g edit
|
||||
|
||||
|
||||
Slackware ARM
|
||||
|
@ -412,8 +412,8 @@ Command Line Tool Usage
|
|||
--remove, list, build, install, Add or remove and print the list
|
||||
build-install of packages. Build and then install
|
||||
the packages from the queue.
|
||||
-g, --config, print, edit=[editor], Configuration file management.
|
||||
reset Print, edit the configuration file
|
||||
-g, --config, print, edit, reset Configuration file management.
|
||||
Print, edit the configuration file
|
||||
or reset in the default values.
|
||||
-l, --list, [repository], --index, Print a list of all available
|
||||
--installed packages repository, index or print
|
||||
|
|
|
@ -109,3 +109,7 @@ ONLY_INSTALLED=off
|
|||
# Enable or disable the progress bar. Status bar progress delays the search
|
||||
# process in package lists. Choose "off" if you need speed. Deafult is "on".
|
||||
PRG_BAR=on
|
||||
|
||||
# Register a text editor that uses the slpkg in a few options.
|
||||
# Default is "nano".
|
||||
EDITOR=nano
|
||||
|
|
|
@ -34,7 +34,7 @@ Usage: slpkg Commands:
|
|||
[-b [package...] --add, --remove, list]
|
||||
[-q [package...] --add, --remove, list]
|
||||
[-q [build, install, build-install]]
|
||||
[-g [print, edit=[editor], reset]]
|
||||
[-g [print, edit, reset]]
|
||||
[-l [repository], --index, --installed]
|
||||
[-c [repository], --upgrade, --skip=[...], --resolve-off,
|
||||
--checklist]
|
||||
|
@ -177,9 +177,9 @@ dependencies. If you want to remove all the packages from the list run "# slpkg
|
|||
Build or install or build and install packages are queued.
|
||||
|
||||
.SS -g, --config, configuration file management
|
||||
\fBslpkg\fP \fB-g\fP \fBprint\fP, \fBedit=[editor]\fP, \fBreset\fP
|
||||
\fBslpkg\fP \fB-g\fP \fBprint\fP, \fBedit\fP, \fBreset\fP
|
||||
.PP
|
||||
Print, reset or edit configuration file with your favorite editor.
|
||||
Print, reset or edit configuration file.
|
||||
|
||||
.SS -l, --list, list of installed packages
|
||||
\fBslpkg\fP \fB-l\fP <\fIrepository\fP>, \fB--index\fP, \fB--installed\fP
|
||||
|
|
|
@ -129,7 +129,8 @@ class MetaData(object):
|
|||
"DOWNDER_OPTIONS": "-c -N",
|
||||
"SLACKPKG_LOG": "on",
|
||||
"ONLY_INSTALLED": "off",
|
||||
"PRG_BAR": "on"
|
||||
"PRG_BAR": "on",
|
||||
"EDITOR": "nano"
|
||||
}
|
||||
|
||||
default_repositories = ["slack", "sbo", "rlw", "alien", "slacky", "studio",
|
||||
|
@ -171,6 +172,7 @@ class MetaData(object):
|
|||
slackpkg_log = _conf_slpkg["SLACKPKG_LOG"]
|
||||
only_installed = _conf_slpkg["ONLY_INSTALLED"]
|
||||
prg_bar = _conf_slpkg["PRG_BAR"]
|
||||
editor = _conf_slpkg["EDITOR"]
|
||||
|
||||
# Remove any gaps
|
||||
repositories = [repo.strip() for repo in repositories]
|
||||
|
|
|
@ -81,8 +81,8 @@ Optional arguments:
|
|||
--remove, list, build, install, Add or remove and print the list
|
||||
build-install of packages. Build and then install
|
||||
the packages from the queue.
|
||||
-g, --config, print, edit=[editor], Configuration file management.
|
||||
reset Print, edit the configuration file
|
||||
-g, --config, print, edit, reset Configuration file management.
|
||||
Print, edit the configuration file
|
||||
or reset in the default values.
|
||||
-l, --list, [repository], --index, Print a list of all available
|
||||
--installed packages repository, index or print
|
||||
|
@ -154,7 +154,7 @@ def usage(repo):
|
|||
[-b [package...] --add, --remove, list]
|
||||
[-q [package...] --add, --remove, list]
|
||||
[-q [build, install, build-install]]
|
||||
[-g [print, edit=[editor], reset]]
|
||||
[-g [print, edit, reset]]
|
||||
[-l [repository], --index, --installed]
|
||||
[-c [repository], --upgrade, --skip=[...], --resolve-off,
|
||||
--checklist]
|
||||
|
|
|
@ -62,7 +62,8 @@ class Config(object):
|
|||
"DOWNDER_OPTIONS",
|
||||
"SLACKPKG_LOG",
|
||||
"ONLY_INSTALLED",
|
||||
"PRG_BAR"
|
||||
"PRG_BAR",
|
||||
"EDITOR"
|
||||
]
|
||||
read_conf = Utils().read_file(self.config_file)
|
||||
try:
|
||||
|
@ -77,11 +78,12 @@ class Config(object):
|
|||
raise SystemExit()
|
||||
print("") # new line at end
|
||||
|
||||
def edit(self, editor):
|
||||
def edit(self):
|
||||
"""
|
||||
Edit configuration file
|
||||
"""
|
||||
subprocess.call("{0} {1}".format(editor, self.config_file), shell=True)
|
||||
subprocess.call("{0} {1}".format(self.meta.editor,
|
||||
self.config_file), shell=True)
|
||||
|
||||
def reset(self):
|
||||
"""Reset slpkg.conf file with default values
|
||||
|
|
|
@ -535,11 +535,10 @@ class ArgParse(object):
|
|||
"""Manage slpkg configuration file
|
||||
"""
|
||||
options = ["-g", "--config"]
|
||||
command = ["print", "edit=", "reset"]
|
||||
command = ["print", "edit", "reset"]
|
||||
if (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1].startswith(command[1])):
|
||||
editor = self.args[1][len(command[1]):]
|
||||
Config().edit(editor)
|
||||
self.args[1] == command[1]):
|
||||
Config().edit()
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == (command[0])):
|
||||
Config().view()
|
||||
|
|
|
@ -202,7 +202,7 @@ class SBoNetwork(object):
|
|||
with open(self.customs_path + filename, "w") as sbo_file:
|
||||
sbo_file.write(contents)
|
||||
subprocess.call(
|
||||
"{0} {1}".format("vim", self.customs_path + filename),
|
||||
"{0} {1}".format(self.meta.editor, self.customs_path + filename),
|
||||
shell=True)
|
||||
|
||||
def view_sbo(self):
|
||||
|
|
Loading…
Reference in a new issue