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.
25 lines
786 B
25 lines
786 B
import subprocess
|
|
import tempfile
|
|
|
|
from .. import pretty
|
|
from .. import color
|
|
from .. import repo
|
|
|
|
def parser(subparsers, config):
|
|
parser = subparsers.add_parser('list', help="list all papers")
|
|
return parser
|
|
|
|
def command(config):
|
|
rp = repo.Repository()
|
|
|
|
articles = []
|
|
for n in range(rp.size()):
|
|
paper = rp.paper_from_number(n, fatal=True)
|
|
bibdesc = pretty.bib_oneliner(paper.bib_data)
|
|
articles.append((u'{:3d} {}{}{}{} {}'.format(int(paper.number), color.purple, paper.citekey, color.end, (10 - len(paper.citekey))*' ', bibdesc)).encode('utf-8'))
|
|
|
|
with tempfile.NamedTemporaryFile(suffix=".tmp", delete=True) as tmpf:
|
|
tmpf.write('\n'.join(articles))
|
|
tmpf.flush()
|
|
subprocess.call(['less', '-XRF', tmpf.name])
|