2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-28 06:49:06 +00:00

fix: Show warning while using experimental features

This shows a "WARNING:..." whenever any --use-feature flag is used
This commit is contained in:
Gavin D'souza 2021-11-26 16:28:18 +05:30
parent 1b2bb87ab7
commit b7994e21b1
3 changed files with 24 additions and 7 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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