diff --git a/slack_backup/command.py b/slack_backup/command.py index 455de21..1bffb85 100644 --- a/slack_backup/command.py +++ b/slack_backup/command.py @@ -90,13 +90,17 @@ def main(): fetch.add_argument('-c', '--channels', default=None, nargs='+', help='List of channels to perform actions on. ' 'Default is all channels.') - fetch.add_argument('-d', '--database', default=None, help='Path to the database file.') - fetch.add_argument('-i', '--config', default=None, help='Use specific config file.') - + fetch.add_argument('-f', '--url_file_to_attachement', default=False, + action='store_true', + help='Treat shared files (but not uploaded to the ' + 'Slack servers) as attachement. By default there will ' + 'be file created in current directory with url and ' + 'path to the filename under which it would be ' + 'registered in the DB.') fetch.set_defaults(func=fetch_data) generate = subparser.add_parser('generate', help='Generate logs out of ' @@ -113,7 +117,6 @@ def main(): choices=('plain', 'unicode'), help='Choose theme for text output. It doesn\'t ' 'affect other output formats.') - generate.add_argument('-v', '--verbose', help='Be verbose. Adding more ' '"v" will increase verbosity', action="count", default=None) @@ -123,13 +126,10 @@ def main(): generate.add_argument('-c', '--channels', default=[], nargs='+', help='List of channels to perform actions on. ' 'Default is all channels.') - generate.add_argument('-d', '--database', default=None, help='Path to the database file.') - generate.add_argument('-i', '--config', default=None, help='Use specific config file.') - generate.set_defaults(func=generate_raport) args = parser.parse_args() diff --git a/slack_backup/config.py b/slack_backup/config.py index abb2753..0871df1 100644 --- a/slack_backup/config.py +++ b/slack_backup/config.py @@ -13,8 +13,10 @@ class Config(object): """Configuration keeper""" ints = ['verbose', 'quiet'] + bools = ['url_file_to_attachement'] - sections = {'common': ['channels', 'database', 'quiet', 'verbose'], + sections = {'common': ['channels', 'database', 'quiet', 'verbose', + 'url_file_to_attachement'], 'fetch': ['user', 'password', 'team', 'token'], 'generate': ['output', 'format', 'theme']} @@ -35,7 +37,8 @@ class Config(object): 'token': None, 'output': None, 'format': None, - 'theme': None} + 'theme': None, + 'url_file_to_attachement': False} # This message supposed to be displayed in INFO level. During the time # of running the code where it should be displayed there is no # complete information about logging level. Displaying message is @@ -79,6 +82,8 @@ class Config(object): for option in self.sections[section]: if option in self.ints: val = self.cp.getint(section, option, fallback=0) + elif option in self.bools: + val = self.cp.getboolean(section, option, fallback=False) elif option == 'channels': val = self.cp.get(section, option, fallback='[]') val = json.loads(val) diff --git a/tests/test_config.py b/tests/test_config.py index d556f98..0fc8c5b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -63,7 +63,8 @@ class TestConfig(unittest.TestCase): 'user': None, 'password': None, 'team': None, - 'token': None}) + 'token': None, + 'url_file_to_attachement': False}) args = argparse.Namespace() args.config = self.confname @@ -97,7 +98,8 @@ class TestConfig(unittest.TestCase): 'team': 'myteam', 'token': 'xxxx-1111111111-' '222222222222-333333333333-' - 'r4nd0ms7uff'}) + 'r4nd0ms7uff', + 'url_file_to_attachement': False}) # override some conf options with commandline args = argparse.Namespace() @@ -124,4 +126,5 @@ class TestConfig(unittest.TestCase): 'user': 'joe', 'password': 'ultricies', 'team': '', - 'token': 'the token'}) + 'token': 'the token', + 'url_file_to_attachement': False})