.. index:: packs_common
.. _packs_common/0:

.. rst-class:: right

**category**

``packs_common``
================

Common predicates for the packs tool objects.

| **Availability:** 
|    ``logtalk_load(packs(loader))``

| **Author:** Paulo Moura
| **Version:** 0:31:0
| **Date:** 2023-11-23

| **Compilation flags:**
|    ``static``


| **Provides:**
|    :ref:`type::type/1 <type/0::type/1>`
|    :ref:`type::check/2 <type/0::check/2>`
| **Uses:**
|    :ref:`list <list/0>`
|    :ref:`logtalk <logtalk/0>`
|    :ref:`os <os/0>`
|    :ref:`type <type/0>`
|    :ref:`user <user/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: setup/0
.. _packs_common/0::setup/0:

``setup/0``
^^^^^^^^^^^

Ensures that registries and packs directory structure exists. Preserves any defined registries and installed packs.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``setup`` - ``one``


------------

.. index:: reset/0
.. _packs_common/0::reset/0:

``reset/0``
^^^^^^^^^^^

Resets registries and packs directory structure. Deletes any defined registries and installed packs.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``reset`` - ``one``


------------

.. index:: verify_commands_availability/0
.. _packs_common/0::verify_commands_availability/0:

``verify_commands_availability/0``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Verifies required shell commands availability. Fails printing an error message if a command is missing.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``verify_commands_availability`` - ``zero_or_one``


------------

.. index:: help/0
.. _packs_common/0::help/0:

``help/0``
^^^^^^^^^^

Provides help about the main predicates.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``help`` - ``one``


------------

.. index:: pin/1
.. _packs_common/0::pin/1:

``pin/1``
^^^^^^^^^

Pins a resource (pack or registry) preventing it from being updated, uninstalled, or deleted. Fails if the resource is not found.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``pin(Resource)``
| **Mode and number of proofs:**
|    ``pin(+atom)`` - ``zero_or_one``

| **Exceptions:**
|    ``Resource`` is a variable:
|        ``instantiation_error``
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``


------------

.. index:: pin/0
.. _packs_common/0::pin/0:

``pin/0``
^^^^^^^^^

Pins all resource (packs or registries) preventing them from being updated, uninstalled, or deleted. Note that resources added after calling this predicate will not be pinned.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``pin`` - ``one``


------------

.. index:: unpin/1
.. _packs_common/0::unpin/1:

``unpin/1``
^^^^^^^^^^^

Unpins a resource (pack or registry), allowing it to be updated, uninstalled, or deleted. Fails if the resource is not found.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``unpin(Resource)``
| **Mode and number of proofs:**
|    ``unpin(+atom)`` - ``zero_or_one``

| **Exceptions:**
|    ``Resource`` is a variable:
|        ``instantiation_error``
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``


------------

.. index:: unpin/0
.. _packs_common/0::unpin/0:

``unpin/0``
^^^^^^^^^^^

Unpins all resources (packs or registries), allowing them to be updated, uninstalled, or deleted.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``unpin`` - ``one``


------------

.. index:: pinned/1
.. _packs_common/0::pinned/1:

``pinned/1``
^^^^^^^^^^^^

True iff the resource (pack or registry) is defined or installed and if it is pinned.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``pinned(Resource)``
| **Mode and number of proofs:**
|    ``pinned(+atom)`` - ``zero_or_one``

| **Exceptions:**
|    ``Resource`` is a variable:
|        ``instantiation_error``
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``


------------

.. index:: directory/2
.. _packs_common/0::directory/2:

``directory/2``
^^^^^^^^^^^^^^^

Enumerates by backtracking all packs or registries and respective installation or definition directories (using the internal backend format).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``directory(Resource,Directory)``
| **Mode and number of proofs:**
|    ``directory(?atom,?atom)`` - ``zero_or_more``

| **Exceptions:**
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``
|    ``Directory`` is neither a variable nor an atom:
|        ``type_error(atom,Directory)``


------------

.. index:: directory/1
.. _packs_common/0::directory/1:

``directory/1``
^^^^^^^^^^^^^^^

Prints the directory where the registry or the pack is installed (using the native operating-system format).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``directory(Resource)``
| **Mode and number of proofs:**
|    ``directory(+atom)`` - ``zero_or_one``

| **Exceptions:**
|    ``Resource`` is a variable:
|        ``instantiation_error``
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``


------------

.. index:: readme/2
.. _packs_common/0::readme/2:

``readme/2``
^^^^^^^^^^^^

Returns the path to the resource (pack or registry) readme file (using the internal backend format). Fails if the resource is not defined or installed or if no readme file is found for it.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``readme(Resource,ReadMeFile)``
| **Mode and number of proofs:**
|    ``readme(+atom,-atom)`` - ``zero_or_one``

| **Exceptions:**
|    ``Resource`` is a variable:
|        ``instantiation_error``
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``
|    ``ReadMeFile`` is neither a variable nor an atom:
|        ``type_error(atom,ReadMeFile)``


------------

.. index:: readme/1
.. _packs_common/0::readme/1:

``readme/1``
^^^^^^^^^^^^

Prints the path to the resource (pack or registry) readme file (using the native operating-system format). Fails if the resource is not defined or installed or if no readme file is found for it.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``readme(Resource)``
| **Mode and number of proofs:**
|    ``readme(+atom)`` - ``zero_or_one``

| **Exceptions:**
|    ``Resource`` is a variable:
|        ``instantiation_error``
|    ``Resource`` is neither a variable nor an atom:
|        ``type_error(atom,Resource)``


------------

.. index:: logtalk_packs/1
.. _packs_common/0::logtalk_packs/1:

``logtalk_packs/1``
^^^^^^^^^^^^^^^^^^^

Returns the directory prefix (using the internal backend format) where the registries, packs, and archives are installed.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``logtalk_packs(LogtalkPacks)``
| **Mode and number of proofs:**
|    ``logtalk_packs(-atom)`` - ``one``

| **Exceptions:**
|    ``LogtalkPacks`` is neither a variable nor an atom:
|        ``type_error(atom,LogtalkPacks)``


------------

.. index:: logtalk_packs/0
.. _packs_common/0::logtalk_packs/0:

``logtalk_packs/0``
^^^^^^^^^^^^^^^^^^^

Prints the directory prefix (using the native operating-system format) where the registries, packs, and archives are installed.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``logtalk_packs`` - ``one``


------------

.. index:: prefix/1
.. _packs_common/0::prefix/1:

``prefix/1``
^^^^^^^^^^^^

Returns the directory prefix (using the internal backend format) where the registries or packs are installed.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``prefix(Prefix)``
| **Mode and number of proofs:**
|    ``prefix(-atom)`` - ``one``

| **Exceptions:**
|    ``Prefix`` is neither a variable nor an atom:
|        ``type_error(atom,Prefix)``


------------

.. index:: prefix/0
.. _packs_common/0::prefix/0:

``prefix/0``
^^^^^^^^^^^^

Prints the directory prefix (using the native operating-system format) where the registries or packs are installed.

| **Compilation flags:**
|    ``static``

| **Mode and number of proofs:**
|    ``prefix`` - ``one``


------------

Protected predicates
--------------------

.. index:: readme_file_path/2
.. _packs_common/0::readme_file_path/2:

``readme_file_path/2``
^^^^^^^^^^^^^^^^^^^^^^

Returns the absolute path for the given directory readme file if it exists.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``readme_file_path(Directory,ReadMeFile)``
| **Mode and number of proofs:**
|    ``readme_file_path(+atom,-atom)`` - ``zero_or_one``

| **Remarks:**

    - Valid file names: Case variations of ``README`` and ``NOTES`` with or without a ``.md`` or ``.txt`` extension. The recommended file name is ``README.md``.


------------

.. index:: print_readme_file_path/1
.. _packs_common/0::print_readme_file_path/1:

``print_readme_file_path/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Prints the absolute path for the given directory readme file if it exists. Succeeds otherwise.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``print_readme_file_path(Directory)``
| **Mode and number of proofs:**
|    ``print_readme_file_path(+atom)`` - ``one``


------------

.. index:: command/2
.. _packs_common/0::command/2:

``command/2``
^^^^^^^^^^^^^

Executes a shell command. Prints an error message and fails if the command fails.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``command(Command,FailureMessage)``
| **Mode and number of proofs:**
|    ``command(+atom,@nonvar)`` - ``zero_or_one``


------------

.. index:: load_registry/1
.. _packs_common/0::load_registry/1:

``load_registry/1``
^^^^^^^^^^^^^^^^^^^

Loads all registry files from the given directory.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``load_registry(Directory)``
| **Mode and number of proofs:**
|    ``load_registry(+atom)`` - ``zero_or_one``


------------

.. index:: tar_command/1
.. _packs_common/0::tar_command/1:

``tar_command/1``
^^^^^^^^^^^^^^^^^

Returns the name of the tar command to be used depending on the operating-system.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``tar_command(Command)``
| **Mode and number of proofs:**
|    ``tar_command(-atom)`` - ``one``


------------

.. index:: supported_archive/1
.. _packs_common/0::supported_archive/1:

``supported_archive/1``
^^^^^^^^^^^^^^^^^^^^^^^

True iff the archive format is supported.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``supported_archive(Extension)``
| **Mode and number of proofs:**
|    ``supported_archive(+atom)`` - ``zero_or_one``


------------

.. index:: supported_url_archive/1
.. _packs_common/0::supported_url_archive/1:

``supported_url_archive/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^

True iff the URL archive is supported.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``supported_url_archive(URL)``
| **Mode and number of proofs:**
|    ``supported_url_archive(+atom)`` - ``zero_or_one``


------------

.. index:: decode_url_spaces/2
.. _packs_common/0::decode_url_spaces/2:

``decode_url_spaces/2``
^^^^^^^^^^^^^^^^^^^^^^^

Decodes encoded spaces (%20) in URLs to spaces.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``decode_url_spaces(URL,Decoded)``
| **Mode and number of proofs:**
|    ``decode_url_spaces(+atom,-atom)`` - ``one``


------------

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

