summaryrefslogtreecommitdiff
path: root/ports/dsl/nano-bots.rb
blob: 29cc828e584f08f84351a98bd882d513fbf5844c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

require 'dotenv/load'

require_relative '../../static/gem'
require_relative '../../controllers/cartridges'
require_relative '../../controllers/instance'
require_relative '../../controllers/security'
require_relative '../../controllers/interfaces/cli'
require_relative '../../components/stream'

module NanoBot
  def self.new(cartridge: '-', state: '-', environment: {})
    Controllers::Instance.new(
      cartridge_path: cartridge,
      state:,
      stream: Components::Stream.new,
      environment:
    )
  end

  def self.security
    Controllers::Security
  end

  def self.cartridges
    Controllers::Cartridges.all
  end

  def self.cli
    Controllers::Interfaces::CLI.handle!
  end

  def self.repl(cartridge: '-', state: '-', environment: {})
    Controllers::Instance.new(
      cartridge_path: cartridge, state:, stream: $stdout, environment:
    ).repl
  end

  def self.version
    NanoBot::GEM[:version]
  end
end