Allow passing named arguments to custom commands.

This allows passing named arguments to custom commands. An example would be `pubs search keyword --ignore-author` and the corresponding alias would redirect the call to the custom script like follows: `search = !"$DOTFILES/pubs/scripts/search.py" "$@"`.
main
Jonáš Kulhánek 5 years ago committed by Fabien C. Y. Benureau
parent 89429a8c24
commit 0777a99d30
No known key found for this signature in database
GPG Key ID: C3FB5E831A249A9A

@ -1,5 +1,6 @@
import shlex
import subprocess
import argparse
from pipes import quote as shell_quote
from ...plugins import PapersPlugin
@ -19,7 +20,7 @@ class Alias(object):
def parser(self, parser):
self.parser = parser
p = parser.add_parser(self.name, help=self.description)
p.add_argument('arguments', nargs='*',
p.add_argument('arguments', nargs=argparse.REMAINDER,
help="arguments to be passed to %s" % self.name)
return p

Loading…
Cancel
Save