You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
#!/usr/bin/env python2
|
|
# -*- coding:utf-8 -*-
|
|
|
|
|
|
import argparse
|
|
import collections
|
|
|
|
from papers.ui import UI
|
|
from papers import configs
|
|
from papers import commands
|
|
from papers import plugins
|
|
|
|
cmds = collections.OrderedDict([
|
|
('init', commands.init_cmd),
|
|
('add', commands.add_cmd),
|
|
('add_library', commands.add_library_cmd),
|
|
('import', commands.import_cmd),
|
|
('export', commands.export_cmd),
|
|
('list', commands.list_cmd),
|
|
('edit', commands.edit_cmd),
|
|
('remove', commands.remove_cmd),
|
|
('open', commands.open_cmd),
|
|
('websearch', commands.websearch_cmd),
|
|
('tags', commands.tags_cmd),
|
|
('attach', commands.attach_cmd),
|
|
])
|
|
|
|
config = configs.read_config()
|
|
ui = UI(config)
|
|
|
|
# Extend with plugin commands
|
|
plugins.load_plugins(config, ui, configs.get_plugins(config))
|
|
for p in plugins.get_plugins().values():
|
|
cmds.update(collections.OrderedDict([(p.name, p)]))
|
|
#
|
|
|
|
parser = argparse.ArgumentParser(description="research papers repository")
|
|
subparsers = parser.add_subparsers(title="valid commands", dest="command")
|
|
|
|
for cmd_mod in cmds.values():
|
|
subparser = cmd_mod.parser(subparsers, config)
|
|
|
|
args = parser.parse_args()
|
|
args.config = config
|
|
args.ui = ui
|
|
cmd = args.command
|
|
del args.command
|
|
|
|
cmds[cmd].command(**vars(args))
|