|
Packit Service |
21c75c |
..
|
|
Packit Service |
21c75c |
Copyright (C) 2014-2018 Red Hat, Inc.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
This copyrighted material is made available to anyone wishing to use,
|
|
Packit Service |
21c75c |
modify, copy, or redistribute it subject to the terms and conditions of
|
|
Packit Service |
21c75c |
the GNU General Public License v.2, or (at your option) any later version.
|
|
Packit Service |
21c75c |
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
21c75c |
ANY WARRANTY expressed or implied, including the implied warranties of
|
|
Packit Service |
21c75c |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit Service |
21c75c |
Public License for more details. You should have received a copy of the
|
|
Packit Service |
21c75c |
GNU General Public License along with this program; if not, write to the
|
|
Packit Service |
21c75c |
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
21c75c |
02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
Packit Service |
21c75c |
source code or documentation are not subject to the GNU General Public
|
|
Packit Service |
21c75c |
License and may only be used or replicated with the express permission of
|
|
Packit Service |
21c75c |
Red Hat, Inc.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
==============================
|
|
Packit Service |
21c75c |
Command Line Interface Hooks
|
|
Packit Service |
21c75c |
==============================
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. module:: dnf.cli
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
:mod:`dnf.cli` is a part of DNF that contains code handling the command line tasks for DNF, like for instance ``dnf install emacs``, and outputs the results to the terminal. It is usually of no interest for DNF extension applications, but some parts of it described here can be used by the :doc:`api_plugins` to hook up custom commands.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
When packaging your custom command, we recommend you to define a virtual provide in the form of ``Provides: dnf-command(<alias>)`` in the spec file. See :ref:`the virtual provides usage <command_provides-label>` for the details.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. exception:: CliError
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Signals a CLI-specific problem (reading configuration, parsing user input, etc.). Derives from :exc:`dnf.exceptions.Error`.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. class:: dnf.cli.demand.DemandSheet
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Instances are used to track requests of commands and plugins about how CLI should set up/handle other parts of CLI processing that are not under the command's/plugin's direct control. The boolean attributes of the sheet can not be reset once explicitly set, doing so raises an :exc:`AttributeError`.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: allow_erasing
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, the dependency solver is allowed to look for solutions that include removing other packages while looking to fulfill the current packaging requests. Defaults to ``False``. Also see :meth:`dnf.Base.resolve`.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: available_repos
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, during sack creation (:attr:`.sack_activation`), download and load into the sack the available repositories. Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: resolving
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, at a place where the CLI would otherwise successfully exit, resolve the transaction for any outstanding packaging requests before exiting. Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: root_user
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
``True`` informs the CLI that the command can only succeed if the process's effective user id is ``0``, i.e. root. Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: sack_activation
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, demand that the CLI sets up the :class:`~.Sack` before the command's :meth:`~.Command.run` method is executed. Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Depending on other demands and the user's configuration, this might or might not correctly trigger metadata download for the available repositories.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: load_system_repo
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, DNF will load information about installed packages from the local RPMDB into the sack during :meth:`dnf.Base.fill_sack`. Defaults to ``True``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: cacheonly
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
When ``True``, DNF will run entirely from the system cache (equivalent of ``-C`` command line option). Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: fresh_metadata
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
``False`` means that (even expired) cached repository metadata will be used. When ``True``, the expired repository metadata caches are synchronized with server. Defaults to ``True``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: freshest_metadata
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, metadata caches for all enabled repositories are forcibly expired before the sack is activated. Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: changelogs
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
If ``True``, also the repository metadata containing changelogs for packages will be downloaded. Defaults to ``False``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: success_exit_status
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The return status of the DNF command on success. Defaults to ``0``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: transaction_display
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
An additional instance of a subclass of :class:`dnf.callback.TransactionProgress` used to report information about an ongoing transaction. Defaults to ``None``.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. class:: Command
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Base class of every DNF command.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: aliases
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Sequence of strings naming the command from the command line. Must be a class variable. The list has to contain at least one string, the first string in the list is considered the canonical name. A command name can be contain only letters and dashes providing the name doesn't start with a dash.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: base
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The :class:`dnf.Base` instance to use with this command.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: cli
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
The :class:`dnf.cli.Cli` instance to use with this command.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: summary
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
One line summary for the command as displayed by the CLI help.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. method:: __init__(cli)
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Command constructor which can be overridden. The constructor is called during
|
|
Packit Service |
21c75c |
CLI configure phase when one of the command's aliases is parsed from `dnf`
|
|
Packit Service |
21c75c |
commandline. `cli` is an instance of :class:`dnf.cli.Cli`.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. method:: pre_configure()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Perform any pre-configuration on the command itself and on the CLI. Typically, the command
|
|
Packit Service |
21c75c |
implements this call to set up releasever or enable/disable repository. This method is called
|
|
Packit Service |
21c75c |
before configuration of repos.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. method:: configure()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
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.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. method:: run()
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Run the command. This method is invoked by the CLI when this command is executed. Should raise :exc:`dnf.exceptions.Error` with a proper message if the command fails. Otherwise should return ``None``. Custom commands typically override this method and put their main work code here.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. class:: Cli
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Manages the CLI, including reading configuration, parsing the command line and running commands.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. attribute:: demands
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
An instance of :class:`~dnf.cli.demand.DemandSheet`, exposed to allow custom commands and plugins influence how the CLI will operate.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. method:: register_command(command_cls):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Register new command. `command_cls` is a subclass of :class:`.Command`.
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
.. method:: redirect_logger(self, stdout=None, stderr=None):
|
|
Packit Service |
21c75c |
|
|
Packit Service |
21c75c |
Change minimal logger level for terminal output to stdout and stderr according to specific
|
|
Packit Service |
21c75c |
command requirements. For stdout and stderr use logging.INFO, logging.WARNING, etc.
|