#!/usr/bin/env python3

# Copyright 2010-2017 Mads Michelsen (mail@brokkr.net)
# This file is part of Poca.
# Poca is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.

"""A subscription management tool for poca"""


import poca


def main():
    '''Main script'''
    args = poca.args.get_poca_subscribe_args()
    args.quiet = False
    args.glyphs = 'default'
    stream_logger = poca.loggers.start_stream_logger(args)
    conf = poca.config.Config(args, merge_default=False)
    if args.cmd_name == 'delete':
        poca.subscribe.delete(conf, args)
    elif args.cmd_name == 'add':
        sub_dic, sub_category = poca.subscribe.user_input_add_sub()
        if sub_dic is not None:
            poca.subscribe.add_sub(conf, sub_category, sub_dic)
    elif args.cmd_name == 'list':
        poca.subscribe.list_subs(conf)
    elif args.cmd_name == 'toggle':
        poca.subscribe.toggle(conf, args)
    elif args.cmd_name == 'stats':
        poca.subscribe.stats(conf, args)
    elif args.cmd_name == 'tags':
        poca.subscribe.list_valid_tags(args)


if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass
