Custom APP Command?

How to define a command like bench XXXX on a specific site? I want to run a command to push some async celery task.

Specify site by adding the --site option

Eg :

bench --site sitename.com <command>

thanks, but how to define a custom command?

You have to add commands.py to your app directory.

Have a look at how we’ve done it here :

import click
import frappe



click.disable_unicode_literals_warning = True


@click.command('make_purchase_receipt')
@click.argument("po")
def make_purchase_receipt(po=None):
	print po

I put this file to APP/commands.py, but bench make_purchase_receipt didn’t work. still

Usage: bench [OPTIONS] COMMAND [ARGS]...

Error: No such command "make_purchase_receipt".

You don’t need to include every command in commands.py. You can also execute a function by using bench --site <your_site_name> execute <method_with_its_path>

3 Likes

Nice! Got it! Thank YOU!