2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-17 02:25:16 +00:00

style: Black-ish make & app

This commit is contained in:
Gavin D'souza 2021-11-29 18:56:33 +05:30
parent 8275d678f4
commit a17af670df
2 changed files with 31 additions and 18 deletions

View File

@ -319,7 +319,6 @@ def get_app(
os.chdir(bench_path) os.chdir(bench_path)
bench_setup = True bench_setup = True
if bench_setup and bench_cli.from_command_line and bench_cli.dynamic_feed: if bench_setup and bench_cli.from_command_line and bench_cli.dynamic_feed:
_bench.LOG_BUFFER.append({ _bench.LOG_BUFFER.append({
"message": f"Fetching App {repo_name}", "message": f"Fetching App {repo_name}",

View File

@ -82,7 +82,7 @@ def init(
python=python, python=python,
verbose=verbose, verbose=verbose,
) )
log(f'Bench {path} initialized', level=1) log(f"Bench {path} initialized", level=1)
except SystemExit: except SystemExit:
raise raise
except Exception: except Exception:
@ -102,8 +102,8 @@ def init(
shutil.rmtree(path) shutil.rmtree(path)
@click.command('drop') @click.command("drop")
@click.argument('path') @click.argument("path")
def drop(path): def drop(path):
from bench.bench import Bench from bench.bench import Bench
from bench.exceptions import BenchNotFoundError, ValidationError from bench.exceptions import BenchNotFoundError, ValidationError
@ -118,8 +118,7 @@ def drop(path):
bench.drop() bench.drop()
print('Bench dropped') print("Bench dropped")
@click.command( @click.command(
@ -149,42 +148,57 @@ def get_app(
) )
@click.command('new-app', help='Create a new Frappe application under apps folder') @click.command("new-app", help="Create a new Frappe application under apps folder")
@click.argument('app-name') @click.argument("app-name")
def new_app(app_name): def new_app(app_name):
from bench.app import new_app from bench.app import new_app
new_app(app_name) new_app(app_name)
@click.command(['remove', 'rm', 'remove-app'], help='Completely remove app from bench and re-build assets if not installed on any site') @click.command(
@click.argument('app-name') ["remove", "rm", "remove-app"],
help=(
"Completely remove app from bench and re-build assets if not installed on any site"
),
)
@click.argument("app-name")
def remove_app(app_name): def remove_app(app_name):
from bench.bench import Bench from bench.bench import Bench
bench = Bench(".") bench = Bench(".")
bench.uninstall(app_name) bench.uninstall(app_name)
@click.command('exclude-app', help='Exclude app from updating') @click.command("exclude-app", help="Exclude app from updating")
@click.argument('app_name') @click.argument("app_name")
def exclude_app_for_update(app_name): def exclude_app_for_update(app_name):
from bench.app import add_to_excluded_apps_txt from bench.app import add_to_excluded_apps_txt
add_to_excluded_apps_txt(app_name) add_to_excluded_apps_txt(app_name)
@click.command('include-app', help='Include app for updating') @click.command("include-app", help="Include app for updating")
@click.argument('app_name') @click.argument("app_name")
def include_app_for_update(app_name): def include_app_for_update(app_name):
"Include app from updating" "Include app from updating"
from bench.app import remove_from_excluded_apps_txt from bench.app import remove_from_excluded_apps_txt
remove_from_excluded_apps_txt(app_name) remove_from_excluded_apps_txt(app_name)
@click.command('pip', context_settings={"ignore_unknown_options": True, "help_option_names": []}, help="For pip help use `bench pip help [COMMAND]` or `bench pip [COMMAND] -h`") @click.command(
@click.argument('args', nargs=-1) "pip",
context_settings={"ignore_unknown_options": True, "help_option_names": []},
help="For pip help use `bench pip help [COMMAND]` or `bench pip [COMMAND] -h`",
)
@click.argument("args", nargs=-1)
@click.pass_context @click.pass_context
def pip(ctx, args): def pip(ctx, args):
"Run pip commands in bench env" "Run pip commands in bench env"
import os import os
from bench.utils.bench import get_env_cmd from bench.utils.bench import get_env_cmd
env_py = get_env_cmd('python')
os.execv(env_py, (env_py, '-m', 'pip') + args) env_py = get_env_cmd("python")
os.execv(env_py, (env_py, "-m", "pip") + args)