updated init cmd, configs + bumped to version 4
This commit is contained in:
parent
a774a1604e
commit
6190890646
@ -1 +1 @@
|
||||
__version__ = 3
|
||||
__version__ = 4
|
@ -1,12 +1,12 @@
|
||||
import add_cmd
|
||||
import import_cmd
|
||||
import export_cmd
|
||||
import init_cmd
|
||||
import list_cmd
|
||||
import open_cmd
|
||||
import edit_cmd
|
||||
import remove_cmd
|
||||
import websearch_cmd
|
||||
import tag_cmd
|
||||
import attach_cmd
|
||||
import update_cmd
|
||||
# import add_cmd
|
||||
# import import_cmd
|
||||
# import export_cmd
|
||||
# import list_cmd
|
||||
# import edit_cmd
|
||||
# import remove_cmd
|
||||
# import open_cmd
|
||||
# import websearch_cmd
|
||||
# import tag_cmd
|
||||
# import attach_cmd
|
||||
# import update_cmd
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
import os
|
||||
|
||||
from ..repo import Repository
|
||||
from .. import databroker
|
||||
from ..configs import config
|
||||
from ..uis import get_ui
|
||||
from .. import color
|
||||
from .. import files
|
||||
|
||||
|
||||
def parser(subparsers):
|
||||
parser = subparsers.add_parser('init',
|
||||
help="initialize the papers directory")
|
||||
parser.add_argument('-p', '--path', default=None,
|
||||
parser.add_argument('-p', '--pubsdir', default=None,
|
||||
help='path to papers directory (if none, ~/.papers is used)')
|
||||
parser.add_argument('-d', '--doc-dir', default=None,
|
||||
help=('path to document directory (if none, documents '
|
||||
'are stored in the same directory)'))
|
||||
parser.add_argument('-d', '--docsdir', default='docsdir://',
|
||||
help=('path to document directory (if not specified, documents will'
|
||||
'be stored in /path/to/pubsdir/doc/)'))
|
||||
return parser
|
||||
|
||||
|
||||
@ -23,20 +23,24 @@ def command(args):
|
||||
"""Create a .papers directory"""
|
||||
|
||||
ui = get_ui()
|
||||
path = args.path
|
||||
doc_dir = args.doc_dir
|
||||
pubsdir = args.pubsdir
|
||||
docsdir = args.docsdir
|
||||
|
||||
if path is not None:
|
||||
config().papers_dir = files.clean_path(os.getcwd(), path)
|
||||
ppd = config().papers_dir
|
||||
if os.path.exists(ppd) and len(os.listdir(ppd)) > 0:
|
||||
if pubsdir is None:
|
||||
pubsdir = '~/.papers'
|
||||
|
||||
pubsdir = os.path.normpath(os.path.abspath(os.path.expanduser(pubsdir)))
|
||||
|
||||
if os.path.exists(pubsdir) and len(os.listdir(pubsdir)) > 0:
|
||||
ui.error('directory {} is not empty.'.format(
|
||||
color.dye(ppd, color.filepath)))
|
||||
color.dye(pubsdir, color.filepath)))
|
||||
ui.exit()
|
||||
|
||||
ui.print_('Initializing papers in {}.'.format(
|
||||
color.dye(ppd, color.filepath)))
|
||||
color.dye(pubsdir, color.filepath)))
|
||||
|
||||
repo = Repository(config(), load = False)
|
||||
repo.save()
|
||||
config().pubsdir = pubsdir
|
||||
config().docsdir = docsdir
|
||||
config().save()
|
||||
|
||||
databroker.DataBroker(pubsdir, create=True)
|
||||
|
@ -1,4 +1,6 @@
|
||||
import os
|
||||
import collections
|
||||
|
||||
from .p3 import configparser
|
||||
|
||||
# constant stuff (DFT = DEFAULT)
|
||||
@ -12,18 +14,18 @@ except KeyError:
|
||||
|
||||
DFT_PLUGINS = ''
|
||||
|
||||
DFT_CONFIG = {'papers_dir' : os.path.expanduser('~/.papers'),
|
||||
'doc_dir' : 'doc',
|
||||
'import_copy' : True,
|
||||
'import_move' : False,
|
||||
'color' : True,
|
||||
'version' : 3,
|
||||
'version_warning' : True,
|
||||
|
||||
'open_cmd' : 'open',
|
||||
'edit_cmd' : DFT_EDIT_CMD,
|
||||
'plugins' : DFT_PLUGINS
|
||||
}
|
||||
DFT_CONFIG = collections.OrderedDict([
|
||||
('pubsdir', os.path.expanduser('~/.papers')),
|
||||
('docsdir', ''),
|
||||
('import_copy', True),
|
||||
('import_move', False),
|
||||
('color', True),
|
||||
('version', 4),
|
||||
('version_warning', True),
|
||||
('open_cmd', 'open'),
|
||||
('edit_cmd', DFT_EDIT_CMD),
|
||||
('plugins', DFT_PLUGINS)
|
||||
])
|
||||
|
||||
BOOLEANS = {'import_copy', 'import_move', 'color', 'version_warning'}
|
||||
|
||||
|
@ -14,17 +14,17 @@ from .__init__ import __version__
|
||||
|
||||
CORE_CMDS = collections.OrderedDict([
|
||||
('init', commands.init_cmd),
|
||||
('add', commands.add_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),
|
||||
('tag', commands.tag_cmd),
|
||||
('attach', commands.attach_cmd),
|
||||
('update', commands.update_cmd),
|
||||
# ('add', commands.add_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),
|
||||
# ('tag', commands.tag_cmd),
|
||||
# ('attach', commands.attach_cmd),
|
||||
# ('update', commands.update_cmd),
|
||||
])
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user