@ -34,10 +34,19 @@ def parser(subparsers, conf):
) . completer = CommaSeparatedTagsCompletion ( conf )
) . completer = CommaSeparatedTagsCompletion ( conf )
parser . add_argument ( ' -k ' , ' --citekey ' , help = ' citekey associated with the paper; \n if not provided, one will be generated automatically. ' ,
parser . add_argument ( ' -k ' , ' --citekey ' , help = ' citekey associated with the paper; \n if not provided, one will be generated automatically. ' ,
default = None , type = p3 . u_maybe )
default = None , type = p3 . u_maybe )
parser . add_argument ( ' -L ' , ' --link ' , action = ' store_false ' , dest = ' copy ' , default = True ,
doc_add_group = parser . add_mutually_exclusive_group ( )
doc_add_group . add_argument (
' -L ' , ' --link ' , action = ' store_const ' , dest = ' doc_add ' , const = ' link ' ,
default = None ,
help = " don ' t copy document files, just create a link. " )
help = " don ' t copy document files, just create a link. " )
parser . add_argument ( ' -M ' , ' --move ' , action = ' store_true ' , dest = ' move ' , default = False ,
doc_add_group . add_argument (
help = " move document instead of of copying (ignored if --link). " )
' -M ' , ' --move ' , action = ' store_const ' , dest = ' doc_add ' , const = ' move ' ,
default = None ,
help = " move document instead of of copying. " )
doc_add_group . add_argument (
' -C ' , ' --copy ' , action = ' store_const ' , dest = ' doc_add ' , const = ' copy ' ,
default = None ,
help = " copy document instead of of move. " )
return parser
return parser
@ -136,25 +145,20 @@ def command(conf, args):
' {} , using {} instead. ' ) . format ( bib_docfile , docfile ) )
' {} , using {} instead. ' ) . format ( bib_docfile , docfile ) )
# create the paper
# create the paper
copy = args . copy
doc_add = args . doc_add
if copy is None :
if doc_add is None :
copy = conf [ ' main ' ] [ ' doc_add ' ] in ( ' copy ' , ' move ' )
doc_add = conf [ ' main ' ] [ ' doc_add ' ]
move = args . move
if move is None :
move = conf [ ' main ' ] [ ' doc_add ' ] == ' move '
rp . push_paper ( p )
rp . push_paper ( p )
ui . message ( ' added to pubs: \n {} ' . format ( pretty . paper_oneliner ( p ) ) )
ui . message ( ' added to pubs: \n {} ' . format ( pretty . paper_oneliner ( p ) ) )
if docfile is not None :
if docfile is not None :
rp . push_doc ( p . citekey , docfile , copy = copy or args . move )
rp . push_doc ( p . citekey , docfile , copy = ( doc_add in ( ' copy ' , ' move ' ) ) )
if copy :
if doc_add == ' move ' and content . content_type ( docfile ) != ' url ' :
if move :
content . remove_file ( docfile )
content . remove_file ( docfile )
if copy :
if doc_add == ' move ' :
if move :
ui . message ( ' {} was moved to the pubs repository. ' . format ( docfile ) )
ui . message ( ' {} was moved to the pubs repository. ' . format ( docfile ) )
else :
elif doc_add == ' copy ' :
ui . message ( ' {} was copied to the pubs repository. ' . format ( docfile ) )
ui . message ( ' {} was copied to the pubs repository. ' . format ( docfile ) )
rp . close ( )
rp . close ( )