From 0540890cb93fc84034d6fce4ff3e811e43bed3a2 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sat, 20 Aug 2022 04:54:41 -0500 Subject: [PATCH] Apply the correct number of arguments to a function --- vultron/cmd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vultron/cmd.py b/vultron/cmd.py index f99a6cf..ce8bb84 100644 --- a/vultron/cmd.py +++ b/vultron/cmd.py @@ -38,6 +38,8 @@ class Command: self.needs_api_key = True self.default = "help" + # FIXME: add support for argument parsing + self.init() if self.needs_api_key and api_key is None: @@ -48,12 +50,13 @@ class Command: def exec_shortcut(self, shortcut, *args): fn = self.find(shortcut) sig = inspect.signature(fn) + parity = len(sig.parameters) - if len(args) < len(sig.parameters): + if len(args) < parity: name = fn.__name__[len(self.FTR_PRFX):].lower() - raise NotEnoughArgs(name, len(sig.parameters) - len(args)) + raise NotEnoughArgs(name, parity - len(args)) - data = fn(*args) + data = fn(*args[:parity]) # FIXME: Let functions choose the output format. This will allow help # functions to still return a rendering.