Commit 3c17198f authored by Samuel GAIST's avatar Samuel GAIST Committed by Samuel GAIST

[scripts][editor_cli] Use new beat/beat.cmdline> environment command to update information

parent 3457169f
......@@ -39,11 +39,10 @@ from click_plugins import with_plugins
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QCoreApplication
from beat.core.dock import Host
from beat.cmdline.click_helper import AliasedGroup
from beat.cmdline.decorators import raise_on_error
from beat.cmdline.decorators import verbosity_option
from beat.cmdline import environments
from ..utils import setup_logger
from ..utils import check_prefix_folders
......@@ -64,19 +63,13 @@ global logger
logger = None
def dump_environments(environments_file_path):
logger.info("Generating environments information")
Host(images_cache=environments_file_path, raise_on_errors=False)
logger.info("Done")
def setup_environment_cache(ctx, param, value):
"""Click option callback to setup environment cache"""
if not value:
environments = ctx.meta["environments"]
if not os.path.exists(environments):
dump_environments(environments)
environments_file_path = ctx.meta["environments"]
if not os.path.exists(environments_file_path):
ctx.invoke(environments.list, type_="all", output=environments_file_path)
def check_prefix(prefix_path):
......@@ -194,15 +187,22 @@ Example:
@editor.command(epilog=ENV_REFRESH_EPILOG)
@click.option(
"--type",
"-t",
"type_",
type=click.Choice(["docker", "remote", "all"], case_sensitive=False),
default="all",
)
@click.pass_context
@raise_on_error
def refresh_env(ctx):
def refresh_env(ctx, type_):
"""Update environments cache"""
environments_file_path = ctx.meta["environments"]
if os.path.exists(environments_file_path):
os.remove(environments_file_path)
dump_environments(environments_file_path)
ctx.invoke(environments.list, type_=type_, output=environments_file_path)
@editor.group(cls=AliasedGroup)
......
......@@ -30,7 +30,7 @@ requirements:
- click
- click-plugins
- docopt
- beat.cmdline >=1.5.0b0
- beat.cmdline >=1.5.1b0
test:
requires:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment