Skip to content

Commit

Permalink
fix: Show warning while using experimental features
Browse files Browse the repository at this point in the history
This shows a "WARNING:..." whenever any --use-feature flag is used
  • Loading branch information
gavindsouza committed Nov 26, 2021
1 parent 1b2bb87 commit b7994e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 3 additions & 2 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
get_venv_path,
get_env_cmd,
)
from bench.utils.render import step
from bench.utils.render import job, step


if TYPE_CHECKING:
Expand Down Expand Up @@ -320,7 +320,7 @@ def __get_installed_apps(self) -> List:
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
"""
Expand All @@ -331,6 +331,7 @@ def requirements(self):
self.pip()

print(f"Installing {len(apps)} applications...")

for app in apps:
App(app, bench=self.bench, to_clone=False).install()

Expand Down
7 changes: 3 additions & 4 deletions bench/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@
# 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)
Expand Down
19 changes: 18 additions & 1 deletion bench/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def print_bench_version(ctx, param, value):
return

import bench

click.echo(bench.VERSION)
ctx.exit()

Expand All @@ -22,7 +23,7 @@ def add_command(self, cmd, name=None):
"""
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:
Expand All @@ -36,18 +37,34 @@ def add_command(self, cmd, name=None):
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

0 comments on commit b7994e2

Please sign in to comment.