|
|
|
@ -2,14 +2,15 @@ from .. import repo
|
|
|
|
|
from .. import color
|
|
|
|
|
from ..configs import config
|
|
|
|
|
from ..uis import get_ui
|
|
|
|
|
from .. import content
|
|
|
|
|
|
|
|
|
|
def parser(subparsers):
|
|
|
|
|
parser = subparsers.add_parser('attach',
|
|
|
|
|
help='attach a document to an existing paper')
|
|
|
|
|
parser.add_argument('-c', '--copy', action='store_true', default=None,
|
|
|
|
|
help="copy document files into library directory (default)")
|
|
|
|
|
parser.add_argument('-C', '--nocopy', action='store_false', dest='copy',
|
|
|
|
|
help="don't copy document files (opposite of -c)")
|
|
|
|
|
# parser.add_argument('-c', '--copy', action='store_true', default=True,
|
|
|
|
|
# help="copy document files into library directory (default)")
|
|
|
|
|
parser.add_argument('-L', '--link', action='store_false', dest='copy', default=True,
|
|
|
|
|
help="don't copy document files, just create a link.")
|
|
|
|
|
parser.add_argument('citekey',
|
|
|
|
|
help='citekey of the paper')
|
|
|
|
|
parser.add_argument('document',
|
|
|
|
@ -30,10 +31,10 @@ def command(args):
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
document = args.document
|
|
|
|
|
document = rp.push_doc(paper.citekey, document, copy=args.copy)
|
|
|
|
|
rp.push_doc(paper.citekey, document, copy=args.copy)
|
|
|
|
|
if args.copy:
|
|
|
|
|
if ui.input_yn('{} has been copied into pubs; should the original be removed?'.format(color.dye(document, color.bold))):
|
|
|
|
|
content.remove_file(docfile)
|
|
|
|
|
content.remove_file(document)
|
|
|
|
|
ui.print_('{} attached to {}'.format(color.dye(document, color.bold), color.dye(paper.citekey, color.citekey)))
|
|
|
|
|
|
|
|
|
|
except ValueError as v:
|
|
|
|
|