def push(cookies, path, stream_name):
	# Override cookies for any new remote objects
	from forge import remote
	remote.override_cookies = cookies

	build(cookies, path, 'reload')
	with cd(path):
		forge_main.handle_primary_options(['reload', 'push', stream_name])
		forge_main.handle_secondary_options('reload', ['push', stream_name])
		forge_main.reload(['push', stream_name])
def run(cookies, path, target):
	# Override cookies for any new remote objects
	from forge import remote
	remote.override_cookies = cookies

	build(cookies, path, target)
	with cd(path):
		# TODO: HAAACK, should extract an interface to the build tools
		# that both the CLI and web interfaces back onto instead of
		# simulating calls to the CLI
		forge_main.handle_primary_options(['run', '-v'])
		forge_main.handle_secondary_options('run', [target])
		forge_main.run(['--general.interactive', 'no'])
def build(cookies, path, target=None):
	# Override cookies for any new remote objects
	from forge import remote
	remote.override_cookies = cookies

	with cd(path):
		# TODO: HAAACK, should extract an interface to the build tools
		# that both the CLI and web interfaces back onto instead of
		# simulating calls to the CLI
		forge_main.handle_primary_options(['build', '-v'])
		forge_main.handle_secondary_options('build', [])
		if target is None:
			forge_main.development_build(['--general.interactive', 'no'], has_target=False)
		else:
			forge_main.development_build([target, '--general.interactive', 'no'])
		_remove_stream_handlers()
def migrate(cookies, path):
	"""Rewrites src/config.json appropriately for a new schema

	:param path: Path to migrate the config file for
	"""
	# Override cookies for any new remote objects
	from forge import remote
	remote.override_cookies = cookies

	with cd(path):
		# TODO: HAAACK, should extract an interface to the build tools
		# that both the CLI and web interfaces back onto instead of
		# simulating calls to the CLI
		forge_main.handle_primary_options(['migrate', '-v'])
		forge_main.handle_secondary_options('migrate', [])
		forge_main.migrate(['--general.interactive', 'no'])