diff options
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/instance.rb | 19 | ||||
-rw-r--r-- | controllers/interfaces/cli.rb | 30 | ||||
-rw-r--r-- | controllers/session.rb | 2 |
3 files changed, 36 insertions, 15 deletions
diff --git a/controllers/instance.rb b/controllers/instance.rb index 243e266..b22a785 100644 --- a/controllers/instance.rb +++ b/controllers/instance.rb @@ -22,8 +22,12 @@ module NanoBot @session = Session.new(provider:, cartridge: @cartridge, state:, stream: @stream) end - def debug - @session.debug + def cartridge + puts YAML.dump(@safe_cartridge) + end + + def state + @session.state end def eval(input) @@ -61,12 +65,11 @@ module NanoBot raise StandardError, "Cartridge file not found: \"#{path}\"" end - @cartridge = Logic::Helpers::Hash.symbolize_keys( - YAML.safe_load( - File.read(elected_path), - permitted_classes: [Symbol] - ) - ) + @cartridge = YAML.safe_load(File.read(elected_path), permitted_classes: [Symbol]) + + @safe_cartridge = Marshal.load(Marshal.dump(@cartridge)) + + @cartridge = Logic::Helpers::Hash.symbolize_keys(@cartridge) inject_environment_variables!(@cartridge) end diff --git a/controllers/interfaces/cli.rb b/controllers/interfaces/cli.rb index 92e468b..2a93044 100644 --- a/controllers/interfaces/cli.rb +++ b/controllers/interfaces/cli.rb @@ -13,14 +13,30 @@ module NanoBot puts NanoBot::GEM[:version] exit when 'help', '', nil + puts '' puts "Nano Bots #{NanoBot::GEM[:version]}" - puts ' nb cartridge.yml - eval "Hello"' + puts '' + puts ' nb - - eval "hello"' + puts ' nb - - repl' + puts '' + puts ' nb cartridge.yml - eval "hello"' puts ' nb cartridge.yml - repl' - puts ' nb cartridge.yml - debug' - puts ' nb cartridge.yml STATE-KEY eval "Hello"' + puts '' + puts ' nb - STATE-KEY eval "hello"' + puts ' nb - STATE-KEY repl' + puts '' + puts ' nb cartridge.yml STATE-KEY eval "hello"' puts ' nb cartridge.yml STATE-KEY repl' - puts ' nb cartridge.yml STATE-KEY debug' + puts '' + puts ' nb - - cartridge' + puts ' nb cartridge.yml - cartridge' + puts '' + puts ' nb - STATE-KEY state' + puts ' nb cartridge.yml STATE-KEY state' + puts '' puts ' nb version' + puts ' nb help' + puts '' exit end @@ -37,8 +53,10 @@ module NanoBot bot.eval(params[:input]) when 'repl' bot.repl - when 'debug' - bot.debug + when 'state' + bot.state + when 'cartridge' + bot.cartridge else raise "TODO: [#{params[:command]}]" end diff --git a/controllers/session.rb b/controllers/session.rb index ad640c8..afaca18 100644 --- a/controllers/session.rb +++ b/controllers/session.rb @@ -31,7 +31,7 @@ module NanoBot end end - def debug + def state pp({ state: { path: @state_path, |