aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/cmd/cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/cmd/cli.py')
-rw-r--r--yardstick/cmd/cli.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/yardstick/cmd/cli.py b/yardstick/cmd/cli.py
index dd74836cb..f2406bf08 100644
--- a/yardstick/cmd/cli.py
+++ b/yardstick/cmd/cli.py
@@ -101,8 +101,7 @@ class YardstickCLI():
cmd_subparsers = subparser.add_subparsers(title='subcommands')
self._find_actions(cmd_subparsers, command_object)
- def main(self, argv):
- '''run the command line interface'''
+ def _register_cli_opt(self):
# register subcommands to parse additional command line arguments
def parser(subparsers):
@@ -114,10 +113,14 @@ class YardstickCLI():
handler=parser)
CONF.register_cli_opt(category_opt)
+ def _load_cli_config(self, argv):
+
# load CLI args and config files
CONF(argv, project="yardstick", version=self._version,
default_config_files=find_config_files(CONFIG_SEARCH_PATHS))
+ def _handle_global_opts(self):
+
# handle global opts
logger = logging.getLogger('yardstick')
logger.setLevel(logging.WARNING)
@@ -128,6 +131,34 @@ class YardstickCLI():
if CONF.debug:
logger.setLevel(logging.DEBUG)
+ def _dispath_func_notask(self):
+
# dispatch to category parser
func = CONF.category.func
func(CONF.category)
+
+ def _dispath_func_task(self, task_id, timestamp):
+
+ # dispatch to category parser
+ func = CONF.category.func
+ func(CONF.category, task_id=task_id, timestamp=timestamp)
+
+ def main(self, argv): # pragma: no cover
+ '''run the command line interface'''
+ self._register_cli_opt()
+
+ self._load_cli_config(argv)
+
+ self._handle_global_opts()
+
+ self._dispath_func_notask()
+
+ def api(self, argv, task_id, timestamp): # pragma: no cover
+ '''run the api interface'''
+ self._register_cli_opt()
+
+ self._load_cli_config(argv)
+
+ self._handle_global_opts()
+
+ self._dispath_func_task(task_id, timestamp)