blob: 59311192148a261bbf967f444a8a5fd0bcdcea7a [file] [log] [blame]
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +05301# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
2# MIT License. See license.txt
3
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +05304import click
5import frappe
Chillar Anand915b3432021-09-02 16:44:59 +05306from frappe.commands import get_site, pass_context
7
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +05308
9def call_command(cmd, context):
10 return click.Context(cmd, obj=context).forward(cmd)
11
12@click.command('make-demo')
13@click.option('--site', help='site name')
14@click.option('--domain', default='Manufacturing')
15@click.option('--days', default=100,
16 help='Run the demo for so many days. Default 100')
17@click.option('--resume', default=False, is_flag=True,
18 help='Continue running the demo for given days')
Rushabh Mehta73167ea2017-06-16 16:55:32 +053019@click.option('--reinstall', default=False, is_flag=True,
20 help='Reinstall site before demo')
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053021@pass_context
Rushabh Mehta73167ea2017-06-16 16:55:32 +053022def make_demo(context, site, domain='Manufacturing', days=100,
23 resume=False, reinstall=False):
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053024 "Reinstall site and setup demo"
25 from frappe.commands.site import _reinstall
26 from frappe.installer import install_app
27
28 site = get_site(context)
29
30 if resume:
31 with frappe.init_site(site):
32 frappe.connect()
33 from erpnext.demo import demo
34 demo.simulate(days=days)
35 else:
Rushabh Mehta73167ea2017-06-16 16:55:32 +053036 if reinstall:
37 _reinstall(site, yes=True)
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053038 with frappe.init_site(site=site):
39 frappe.connect()
40 if not 'erpnext' in frappe.get_installed_apps():
41 install_app('erpnext')
42
43 # import needs site
44 from erpnext.demo import demo
45 demo.make(domain, days)
46
47commands = [
48 make_demo
Ankush Menat4551d7d2021-08-19 13:41:10 +053049]