From 38e5c4a43d56ea48c2706e1722a504b8a1d38ca7 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Thu, 21 Sep 2017 15:47:04 +0200 Subject: [PATCH] Add pre_configuration() def for commands It allows to set up thinks before configuration of repos (like releasever). --- dnf/cli/cli.py | 2 +- dnf/cli/commands/__init__.py | 5 +++++ doc/api_cli.rst | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py index e481cc2d..641b4464 100644 --- a/dnf/cli/cli.py +++ b/dnf/cli/cli.py @@ -878,7 +878,7 @@ class Cli(object): self.demands.cacheonly = True if opts.obsoletes: self.base.conf.obsoletes = True - + self.command.pre_configure() # with cachedir in place we can configure stuff depending on it: self.base._activate_persistor() diff --git a/dnf/cli/commands/__init__.py b/dnf/cli/commands/__init__.py index 7608c851..9a40f779 100644 --- a/dnf/cli/commands/__init__.py +++ b/dnf/cli/commands/__init__.py @@ -124,6 +124,11 @@ class Command(object): """Define command specific options and arguments. #:api""" pass + def pre_configure(self): + # :api + """Do any command-specific pre-configuration.""" + pass + def configure(self): # :api """Do any command-specific configuration.""" diff --git a/doc/api_cli.rst b/doc/api_cli.rst index ab5863b8..71e6860d 100644 --- a/doc/api_cli.rst +++ b/doc/api_cli.rst @@ -90,6 +90,12 @@ When packaging your custom command, we recommend you to define a virtual provide CLI configure phase when one of the command's aliases is parsed from `dnf` commandline. `cli` is an instance of :class:`dnf.cli.Cli`. + .. method:: pre_configure() + + Perform any pre-configuration on the command itself and on the CLI. Typically, the command + implements this call to set up releasever or enable/disable repository. This method is called + before configuration of repos. + .. method:: configure() Perform any configuration on the command itself and on the CLI. Typically, the command implements this call to set up any :class:`demands <.DemandSheet>`, tweak the global configuration or the repository configuration. This method is called immediately after the CLI/extension is finished configuring DNF. -- 2.13.5