From 930c70e06a833e53a91436459d6787d39763b622 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 15 Feb 2019 18:01:06 +0100 Subject: [PATCH] [core] Allow mixing of parameter specs Allow modules and parameters to be specified as either simple lists (-p a b c d) or as multiple instances (-p a -p b -p c). fixes #362 --- bumblebee/config.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bumblebee/config.py b/bumblebee/config.py index 68bd796..5563430 100644 --- a/bumblebee/config.py +++ b/bumblebee/config.py @@ -48,10 +48,10 @@ class print_usage(argparse.Action): def create_parser(): """Create the argument parser""" parser = argparse.ArgumentParser(description="display system data in the i3bar") - parser.add_argument("-m", "--modules", nargs="+", default=[], + parser.add_argument("-m", "--modules", nargs="+", action='append', default=[], help=MODULE_HELP) parser.add_argument("-t", "--theme", default="default", help=THEME_HELP) - parser.add_argument("-p", "--parameters", nargs="+", default=[], + parser.add_argument("-p", "--parameters", nargs="+", action='append', default=[], help=PARAMETER_HELP) parser.add_argument("-l", "--list", choices=["modules", "themes"], action=print_usage, help=LIST_HELP) @@ -82,16 +82,18 @@ class Config(bumblebee.store.Store): if not self._args.debug: logging.getLogger().disabled = True - for param in self._args.parameters: + parameters = [item for sub in self._args.parameters for item in sub] + for param in parameters: key, value = param.split("=") self.set(key, value) def modules(self): + modules = [item for sub in self._args.modules for item in sub] """Return a list of all activated modules""" return [{ "module": x.split(":")[0], "name": x if not ":" in x else x.split(":")[1], - } for x in self._args.modules] + } for x in modules] def theme(self): """Return the name of the selected theme"""