diff options
author | Taseer <taseer94@gmail.com> | 2017-06-02 14:23:55 +0500 |
---|---|---|
committer | Taseer <taseer94@gmail.com> | 2017-06-02 19:41:05 +0500 |
commit | 30f07d0e8e2d82e613155e218d92f126ad1316bf (patch) | |
tree | 0daa3445e6bd359ba6fa0f7c89ff53bf87d062d7 /qtip/cli/commands | |
parent | aa27f390c9ad6817d2682c4f59594f43c69d614f (diff) |
Refactor Cli
- Remove reduntant contexts
- Remove verbose option
- Use builtin help and version options
Change-Id: Ifb66009b5f9ab95428ce87c90f739b5221ccdd6f
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
Diffstat (limited to 'qtip/cli/commands')
-rw-r--r-- | qtip/cli/commands/cmd_metric.py | 15 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_qpi.py | 15 | ||||
-rw-r--r-- | qtip/cli/commands/cmd_report.py | 9 |
3 files changed, 10 insertions, 29 deletions
diff --git a/qtip/cli/commands/cmd_metric.py b/qtip/cli/commands/cmd_metric.py index 1741fb48..0a385898 100644 --- a/qtip/cli/commands/cmd_metric.py +++ b/qtip/cli/commands/cmd_metric.py @@ -14,22 +14,17 @@ import os from qtip.base.error import InvalidContentError from qtip.base.error import NotFoundError from qtip.cli import utils -from qtip.cli.entry import Context from qtip.loader.metric import MetricSpec -pass_context = click.make_pass_decorator(Context, ensure=False) - @click.group() -@pass_context -def cli(ctx): +def cli(): ''' Performance Metrics Group ''' pass @cli.command('list', help='List all the Metric Groups') -@pass_context -def cmd_list(ctx): +def cmd_list(): metrics = MetricSpec.list_all() table = utils.table('Metrics', metrics) click.echo(table) @@ -37,8 +32,7 @@ def cmd_list(ctx): @cli.command('show', help='View details of a Metric') @click.argument('name') -@pass_context -def show(ctx, name): +def show(name): try: metric = MetricSpec('{}.yaml'.format(name)) except NotFoundError as nf: @@ -54,8 +48,7 @@ def show(ctx, name): @cli.command('run', help='Run performance test') @click.argument('name') @click.option('-p', '--path', help='Path to store results') -@pass_context -def run(ctx, name, path): +def run(name, path): runner_path = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'runner/runner.py') os.system('python {0} -b {1} -d {2}'.format(runner_path, name, path)) diff --git a/qtip/cli/commands/cmd_qpi.py b/qtip/cli/commands/cmd_qpi.py index a47442b7..d08842a4 100644 --- a/qtip/cli/commands/cmd_qpi.py +++ b/qtip/cli/commands/cmd_qpi.py @@ -15,22 +15,17 @@ import os from qtip.base.error import InvalidContentError from qtip.base.error import NotFoundError from qtip.cli import utils -from qtip.cli.entry import Context from qtip.loader.qpi import QPISpec -pass_context = click.make_pass_decorator(Context, ensure=False) - @click.group() -@pass_context -def cli(ctx): +def cli(): ''' Collection of performance tests ''' pass @cli.command('list', help='List all the QPI specs') -@pass_context -def cmd_list(ctx): +def cmd_list(): qpis = QPISpec.list_all() table = utils.table('QPIs', qpis) click.echo(table) @@ -38,8 +33,7 @@ def cmd_list(ctx): @cli.command('show', help='View details of a QPI') @click.argument('name') -@pass_context -def show(ctx, name): +def show(name): try: qpi = QPISpec('{}.yaml'.format(name)) except NotFoundError as nf: @@ -55,8 +49,7 @@ def show(ctx, name): @cli.command('run', help='Run performance tests for the specified QPI') @click.argument('name') @click.option('-p', '--path', help='Path to store results') -@pass_context -def run(ctx, name, path): +def run(name, path): runner_path = path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'runner/runner.py') os.system('python {0} -b all -d {1}'.format(runner_path, path)) diff --git a/qtip/cli/commands/cmd_report.py b/qtip/cli/commands/cmd_report.py index ebc0ef77..4176fd90 100644 --- a/qtip/cli/commands/cmd_report.py +++ b/qtip/cli/commands/cmd_report.py @@ -9,15 +9,11 @@ import click -from qtip.cli.entry import Context from qtip.reporter.console import ConsoleReporter -pass_context = click.make_pass_decorator(Context, ensure=False) - @click.group() -@pass_context -def cli(ctx): +def cli(): """ View QTIP results""" pass @@ -25,8 +21,7 @@ def cli(ctx): @cli.command('show') @click.argument('metric') @click.option('-p', '--path', help='Path to result directory') -@pass_context -def show(ctx, metric, path): +def show(metric, path): reporter = ConsoleReporter({}) report = reporter.render(metric, path) click.echo(report) |