From b7994e21b18b5d970e46f55e8fc2db89a2a4407e Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 26 Nov 2021 16:28:18 +0530 Subject: [PATCH] fix: Show warning while using experimental features This shows a "WARNING:..." whenever any --use-feature flag is used --- bench/bench.py | 5 +++-- bench/cli.py | 7 +++---- bench/utils/cli.py | 19 ++++++++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bench/bench.py b/bench/bench.py index 70934efd..ede4bedd 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -28,7 +28,7 @@ from bench.utils.bench import ( get_venv_path, get_env_cmd, ) -from bench.utils.render import step +from bench.utils.render import job, step if TYPE_CHECKING: @@ -320,7 +320,7 @@ class BenchSetup(Base): apps.insert(0, "frappe") return apps - @step(title="Setting Up Bench Dependencies", success="Bench Dependencies Set Up") + @job(title="Setting Up Bench Dependencies", success="Bench Dependencies Set Up") def requirements(self): """Install and upgrade all installed apps on given Bench """ @@ -331,6 +331,7 @@ class BenchSetup(Base): self.pip() print(f"Installing {len(apps)} applications...") + for app in apps: App(app, bench=self.bench, to_clone=False).install() diff --git a/bench/cli.py b/bench/cli.py index 844d64b9..b2eeac13 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -31,17 +31,16 @@ from bench.utils.bench import get_env_cmd # these variables are used to show dynamic outputs on the terminal dynamic_feed = False verbose = False +is_envvar_warn_set = None +from_command_line = False # set when commands are executed via the CLI bench.LOG_BUFFER = [] -# set when commands are executed via the CLI -from_command_line = False - change_uid_msg = "You should not run this command as root" src = os.path.dirname(__file__) def cli(): - global from_command_line, bench_config + global from_command_line, bench_config, is_envvar_warn_set from_command_line = True command = " ".join(sys.argv) diff --git a/bench/utils/cli.py b/bench/utils/cli.py index 1c664b25..7749e00f 100644 --- a/bench/utils/cli.py +++ b/bench/utils/cli.py @@ -8,6 +8,7 @@ def print_bench_version(ctx, param, value): return import bench + click.echo(bench.VERSION) ctx.exit() @@ -22,7 +23,7 @@ class MultiCommandGroup(click.Group): """ name = name or cmd.name if name is None: - raise TypeError('Command has no name.') + raise TypeError("Command has no name.") _check_multicommand(self, name, cmd, register=True) try: @@ -36,18 +37,34 @@ class MultiCommandGroup(click.Group): def use_experimental_feature(ctx, param, value): if not value: return + if value == "dynamic-feed": import bench.cli + bench.cli.dynamic_feed = True bench.cli.verbose = True else: from bench.exceptions import FeatureDoesNotExistError + raise FeatureDoesNotExistError(f"Feature {value} does not exist") + from bench.cli import is_envvar_warn_set + + if is_envvar_warn_set: + return + + click.secho( + "WARNING: bench is using it's new CLI rendering engine. This behaviour has" + f" been enabled by passing --{value} in the command. This feature is" + " experimental and may not be implemented for all commands yet.", + fg="yellow", + ) + def setup_verbosity(ctx, param, value): if not value: return import bench.cli + bench.cli.verbose = True