From 0777a99d3037ddedc4f9631704d123de1146b787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Kulh=C3=A1nek?= Date: Fri, 7 Aug 2020 10:54:45 +0200 Subject: [PATCH] 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" "$@"`. --- pubs/plugs/alias/alias.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubs/plugs/alias/alias.py b/pubs/plugs/alias/alias.py index fd9cae2..5bee03d 100644 --- a/pubs/plugs/alias/alias.py +++ b/pubs/plugs/alias/alias.py @@ -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