From e428f444fba8482a36e7a679a1aa4eeda97cd2b8 Mon Sep 17 00:00:00 2001 From: ted chang Date: Fri, 7 May 2021 17:01:26 -0700 Subject: [PATCH] Update default cli no option help message Signed-off-by: ted chang --- sdk/python/feast/cli.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sdk/python/feast/cli.py b/sdk/python/feast/cli.py index 9055ea5ba8..f4a38b70c3 100644 --- a/sdk/python/feast/cli.py +++ b/sdk/python/feast/cli.py @@ -38,6 +38,19 @@ DATETIME_ISO = "%Y-%m-%dT%H:%M:%s" +class NoOptionDefaultFormat(click.Command): + def format_options(self, ctx: click.Context, formatter: click.HelpFormatter): + """Writes all the options into the formatter if they exist.""" + opts = [] + for param in self.get_params(ctx): + rv = param.get_help_record(ctx) + if rv is not None: + opts.append(rv) + if opts: + with formatter.section("Options(No current command options)"): + formatter.write_dl(opts) + + @click.group() @click.option( "--chdir", @@ -166,7 +179,7 @@ def feature_view_list(ctx: click.Context): print(tabulate(table, headers=["NAME", "ENTITIES"], tablefmt="plain")) -@cli.command("apply") +@cli.command("apply", cls=NoOptionDefaultFormat) @click.pass_context def apply_total_command(ctx: click.Context): """ @@ -183,7 +196,7 @@ def apply_total_command(ctx: click.Context): print(str(e)) -@cli.command("teardown") +@cli.command("teardown", cls=NoOptionDefaultFormat) @click.pass_context def teardown_command(ctx: click.Context): """