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" "$@"`.
This commit is contained in:
parent
89429a8c24
commit
0777a99d30
@ -1,5 +1,6 @@
|
|||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import argparse
|
||||||
from pipes import quote as shell_quote
|
from pipes import quote as shell_quote
|
||||||
|
|
||||||
from ...plugins import PapersPlugin
|
from ...plugins import PapersPlugin
|
||||||
@ -19,7 +20,7 @@ class Alias(object):
|
|||||||
def parser(self, parser):
|
def parser(self, parser):
|
||||||
self.parser = parser
|
self.parser = parser
|
||||||
p = parser.add_parser(self.name, help=self.description)
|
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)
|
help="arguments to be passed to %s" % self.name)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user