#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
The downgraded Hello, World!

In this example we create a shell with one simple command: hello.
Moreover, an automated interaction is ran, and there is no need for internet
access to see the outcome.

Multiple questions are adressed in this example:

- How to avoid chat in the cloud? By selecting a bot with type ``local``, we
  load a minimum textual interface instead of relying on a heavy cloud service.
  Developers will enjoy the capability that is given here to test
  new code interactively, including commands, state machines, or data stores.
  Configuration needs are reduced to the very minimum, and you can stay in a
  terminal window for a larger part of your developments. This is also very
  useful when you do not have access to the internet.

- How to simulate a chat locally? You can inject lines that would be typed
  by a chat participant in the parameter ``input`` of the new bot. When you
  do this, the bot processes all lines one by one, and displays computed
  responses as well. With this approach you can develop and test sophisticated
  interactions, and reproduce them at will.


For example, if you run this script under Linux or macOs::

    python hello_simulator.py


"""

import logging
import os

from shellbot import ShellBot, Context, Command
from shellbot.spaces import SpaceFactory
Context.set_logger(level=logging.INFO)

# create a bot and load command
#
class Hello(Command):
    keyword = 'hello'
    information_message = u"Hello, World!"

bot = ShellBot(command=Hello(), type='local')
bot.space.push(['help', 'hello', 'help help'])

# load configuration
#
bot.configure()

# create a chat room
#
bot.bond(reset=True)

# run the bot
#
bot.run()

# delete the chat room when the bot is stopped
#
bot.dispose()

@@ -2198,16 +2198,22 @@
 reate a 
+local 
 bot and 
@@ -2360,16 +2360,56 @@
 'local')
+%0A%0A# simulate the execution of commands%0A#
 %0Abot.spa
@@ -2453,179 +2453,41 @@
 %5D)%0A%0A
-# load configuration%0A#%0Abot.configure()%0A%0A# create a chat room%0A#%0Abot.bond(reset=True)%0A%0A# run the bot%0A#%0Abot.run()%0A%0A# delete the chat room when the bot is stopped%0A#%0Abot.dispose
+bot.configure()%0Abot.bond()%0Abot.run
 ()%0A

streamline the Hello World simulation