From ea28ce6ab13bc206007ec4c920e9a40cd1564f94 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 23 Jan 2025 23:41:51 -0800 Subject: [PATCH] /* PR_START p--release-0.207.1-updates 05 */ Add `--yes` option to tutorial. --- dbt-metricflow/dbt_metricflow/cli/main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dbt-metricflow/dbt_metricflow/cli/main.py b/dbt-metricflow/dbt_metricflow/cli/main.py index 048fa5436b..9f4fdd5066 100644 --- a/dbt-metricflow/dbt_metricflow/cli/main.py +++ b/dbt-metricflow/dbt_metricflow/cli/main.py @@ -106,10 +106,11 @@ def exit_signal_handler(signal_type: int, frame) -> None: # type: ignore @click.option("-m", "--message", is_flag=True, help="Output the final steps dialogue") # @click.option("--skip-dw", is_flag=True, help="Skip the data warehouse health checks") # TODO: re-enable this @click.option("--clean", is_flag=True, help="Remove sample model files.") +@click.option("--yes", is_flag=True, help="Respond yes to all questions (for scripting).") @pass_config @click.pass_context @log_call(module_name=__name__, telemetry_reporter=_telemetry_reporter) -def tutorial(ctx: click.core.Context, cfg: CLIConfiguration, message: bool, clean: bool) -> None: +def tutorial(ctx: click.core.Context, cfg: CLIConfiguration, message: bool, clean: bool, yes: bool) -> None: """Run user through a tutorial.""" # Needed to handle the backslash outside f-string complex_query = ( @@ -166,7 +167,7 @@ def tutorial(ctx: click.core.Context, cfg: CLIConfiguration, message: bool, clea "Unable to detect a dbt project. Please run this command from the root directory of your dbt project.", fg="yellow", ) - click.confirm( + yes or click.confirm( textwrap.dedent( f"""\ @@ -186,7 +187,7 @@ def tutorial(ctx: click.core.Context, cfg: CLIConfiguration, message: bool, clea abort=True, ) if dbtMetricFlowTutorialHelper.check_if_path_exists([sample_dbt_project_path]): - click.confirm( + yes or click.confirm( click.style( textwrap.dedent( f"""\ @@ -234,7 +235,7 @@ def tutorial(ctx: click.core.Context, cfg: CLIConfiguration, message: bool, clea # Remove sample files from dbt project if clean: - click.confirm("Would you like to remove all the sample files?", abort=True) + yes or click.confirm("Would you like to remove all the sample files?", abort=True) spinner = Halo(text="Removing sample files...", spinner="dots") spinner.start() try: @@ -263,11 +264,11 @@ def tutorial(ctx: click.core.Context, cfg: CLIConfiguration, message: bool, clea """ ) ) - click.confirm("Continue and generate the files?", abort=True) + yes or click.confirm("Continue and generate the files?", abort=True) # Generate sample files into dbt project if dbtMetricFlowTutorialHelper.check_if_path_exists([model_path, seed_path]): - click.confirm( + yes or click.confirm( click.style("There are existing files in the paths above, would you like to overwrite them?", fg="yellow"), abort=True, )