Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit 58b44b0

Browse files
committed
Add documentation about the configuration file.
1 parent 21c09ed commit 58b44b0

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

docs/configuration.rst

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ It is written in Python and should work with Python 3.9+.
1717
quickstart
1818
old-issues
1919
metrics
20+
configuration

docs/quickstart.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Getting Started
33
***************
44

5+
.. _new-conf:
6+
57
Creating a configuration file
68
=============================
79

@@ -46,5 +48,5 @@ The main commands are:
4648
``close``
4749
:ref:`Close old issues <closing-old-issues>` in the repository.
4850

49-
``metrics``:
51+
``metrics``
5052
:doc:`Print some statistics <metrics>` about the repository.

0 commit comments

Comments
 (0)