From 7ccc2bddaac641a321cbdf0d742500cd51b5e84a Mon Sep 17 00:00:00 2001 From: gryf Date: Mon, 28 Nov 2016 16:54:48 +0100 Subject: [PATCH] Added section about config in readme --- README.rst | 54 ++++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- slack_backup/config.py | 7 +----- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 619abcc..e212b49 100644 --- a/README.rst +++ b/README.rst @@ -116,6 +116,60 @@ command. See help for the ``slack-backup`` command for complete list of options. +Configuration +------------- + +For convenience, you can place all of needed options into configuration file +(aka .ini), which all options (with their defaults) will look like: + +.. code:: ini + + [common] + channels = + database = + quiet = 0 + verbose = 0 + + [generate] + output = + format = text + theme = plain + + [fetch] + user = + password = + team = + token = + +Note, that you don't have to put every option. To illustrate ``fetch`` example +from above, here is a corresponding config file: + +.. code:: ini + + [common] + database = mydatabase.sqlite + quiet = 2 + + [fetch] + user = some@email.address.org + password = secret + team = myteam + token = xxxx-1111111111-222222222222-333333333333-r4nd0ms7uff + +Note, that only ``[common]`` and ``[fetch]`` sections are provided, so it is +enough to invoke ``slack-backup`` command as: + +.. code:: shell-session + + (myenv)user@localhost ~/mylogs $ slack-backup fetch + +There are couple of places, where configuration file would be searched for, in +particular order: + +* file provided via argument ``-i`` or ``--config`` +* ``slack-backup.ini`` in current directory +* ``$XDG_CONFIG_HOME/slack-backup.ini``, where ``$XDG_CONFIG_HOME`` usually + defaults to ``$HOME/.config`` Details ------- diff --git a/setup.py b/setup.py index bda1f62..fba1f4c 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ except ImportError: setup(name="slack-backup", packages=["slack_backup"], - version="0.3", + version="0.4", description="Make copy of slack converstaions", author="Roman Dobosz", author_email="gryf73@gmail.com", diff --git a/slack_backup/config.py b/slack_backup/config.py index dd6e776..ca3479d 100644 --- a/slack_backup/config.py +++ b/slack_backup/config.py @@ -53,12 +53,7 @@ class Config(object): def load_config(self, args): - if not args.config: - path = os.path.join(os.path.abspath('.'), 'slack-backup.ini') - else: - path = args.config - - locations = [path, + locations = [args.config, './slack-backup.conf', os.path.expandvars('$XDG_CONFIG_HOME/slack-backup.ini'), os.path.expandvars('$HOME/.config/slack-backup.ini')]