|
| 1 | +************* |
| 2 | +Configuration |
| 3 | +************* |
| 4 | + |
| 5 | +Configuration file location |
| 6 | +=========================== |
| 7 | + |
| 8 | +GrainyHead’s configuration file is looked for, by default, under the path |
| 9 | +``$XDG_CONFIG_HOME/grainyhead/config``. |
| 10 | + |
| 11 | +Another location may be specified using the ``-c`` or ``--config`` option. |
| 12 | + |
| 13 | +If the configuration file (be it the default one or one specified with the |
| 14 | +``-c`` option) does not exist when ``grh`` is called, the ``conf`` command will |
| 15 | +automatically be invoked to prompt the user for enough informations to create a |
| 16 | +minimal configuration file, as shown in :ref:`new-conf`. |
| 17 | + |
| 18 | +Once a configuration file has been created, the ``conf`` command can be |
| 19 | +explicitly used again to edit that file with the user’s preferred text editor. |
| 20 | + |
| 21 | + |
| 22 | +Configuration file syntax |
| 23 | +========================= |
| 24 | + |
| 25 | +The configuration file’s general syntax is that of ``.ini`` files, as supported |
| 26 | +by Python’s :py:mod:`configparser` module. |
| 27 | + |
| 28 | +Briefly, the configuration file is organised into *sections* which start by a |
| 29 | +bracked-enclosed header and contain key-value pairs. |
| 30 | + |
| 31 | +You can use either a colon (``:``) or an equal sign (``=``) to separate keys and |
| 32 | +values. Leading and trailing whitespaces are ignored, as well as lines starting |
| 33 | +with either a semi-colon (``;``) or a number sign (``#``). |
| 34 | + |
| 35 | + |
| 36 | +Configuration of repositories |
| 37 | +============================= |
| 38 | + |
| 39 | +Each section in the configuration file represents a GitHub repository work with. |
| 40 | + |
| 41 | +There must be at least one section, which *must* be called ``default``. It |
| 42 | +describes the repository that will be used by default. |
| 43 | + |
| 44 | +To work with more repositories, add more sections to the configuration file, |
| 45 | +giving each section a unique name. On the command line, select the section (and |
| 46 | +therefore the repository) to use with the ``-s`` or ``--section`` option, which |
| 47 | +expects the name of a configuration section. |
| 48 | + |
| 49 | +Each section must have two keys: |
| 50 | + |
| 51 | +``repository`` |
| 52 | + This is the address to the GitHub repository. It can either be a full URL |
| 53 | + (e.g., ``https://github.com/gouttegd/grainyhead``), or more simply just the |
| 54 | + name of the GitHub account followed by the name of the repository (e.g., |
| 55 | + ``gouttegd/grainyhead``). |
| 56 | + |
| 57 | +``token`` |
| 58 | + This is the *personal access token* needed to access the repository through |
| 59 | + the GitHub API. See `GitHub documentation`_ for details on how to obtain |
| 60 | + such a token. |
| 61 | + |
| 62 | +.. _GitHub documentation: https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token |
| 63 | + |
| 64 | +Note that even if you use a single token to access several repositories |
| 65 | +(possibly all your repositories), the token must be explicitly specified in each |
| 66 | +configuration section. |
0 commit comments