pubs/papers/commands/list_cmd.py
Fabien Benureau cdd2796638 finished implementing the classes
a lowercase bug remain that force to move to another format than configparser. Which is just as well.
2012-10-11 09:26:46 +02:00

25 lines
753 B
Python

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 rp.numbers:
paper = rp.paper_from_number(n, fatal = True)
bibdesc = pretty.bib_oneliner(paper.bibdata)
articles.append('{:3d} {}{}{}{} {}'.format(int(paper.number), color.purple, citekey, color.end, (8-len(paper.citekey))*' ', bibdesc))
with tempfile.NamedTemporaryFile(suffix=".tmp", delete=True) as tmpf:
tmpf.write('\n'.join(articles))
tmpf.flush()
subprocess.call(['less', '-XRF', tmpf.name])