mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 17:24:41 +00:00
feat: Aliased Commands
* Added alias for get-app as get * Now run `bench get erpnext` to install ERPNext on your bench
This commit is contained in:
parent
906ad5a099
commit
b75d352454
@ -1,5 +1,5 @@
|
||||
import click
|
||||
|
||||
from click.core import _check_multicommand
|
||||
|
||||
def print_bench_version(ctx, param, value):
|
||||
"""Prints current bench version"""
|
||||
@ -10,7 +10,28 @@ def print_bench_version(ctx, param, value):
|
||||
click.echo(bench.VERSION)
|
||||
ctx.exit()
|
||||
|
||||
@click.group()
|
||||
class MultiCommandGroup(click.Group):
|
||||
def add_command(self, cmd, name=None):
|
||||
"""Registers another :class:`Command` with this group. If the name
|
||||
is not provided, the name of the command is used.
|
||||
|
||||
Note: This is a custom Group that allows passing a list of names for
|
||||
the command name.
|
||||
"""
|
||||
name = name or cmd.name
|
||||
if name is None:
|
||||
raise TypeError('Command has no name.')
|
||||
_check_multicommand(self, name, cmd, register=True)
|
||||
|
||||
try:
|
||||
self.commands[name] = cmd
|
||||
except TypeError:
|
||||
if isinstance(name, list):
|
||||
for _name in name:
|
||||
self.commands[_name] = cmd
|
||||
|
||||
|
||||
@click.group(cls=MultiCommandGroup)
|
||||
@click.option('--version', is_flag=True, is_eager=True, callback=print_bench_version, expose_value=False)
|
||||
def bench_command(bench_path='.'):
|
||||
import bench
|
||||
|
@ -57,7 +57,7 @@ def drop(path):
|
||||
drop_bench(path)
|
||||
|
||||
|
||||
@click.command('get-app', help='Clone an app from the internet or filesystem and set it up in your bench')
|
||||
@click.command(['get', 'get-app'], help='Clone an app from the internet or filesystem and set it up in your bench')
|
||||
@click.argument('name', nargs=-1) # Dummy argument for backward compatibility
|
||||
@click.argument('git-url')
|
||||
@click.option('--branch', default=None, help="branch to checkout")
|
||||
|
Loading…
Reference in New Issue
Block a user