Installation
Add this line to your application’s Gemfile:
gem 'alki-console'
And then execute:
$ bundle --binstubs
Running
In an Alki project, run bin/alki-console
. Once run a prompt will be displayed
and assembly elements will be directly accessible.
config/assembly.rb
Alki do
group :settings do
set :message, 'Hello World'
end
end
$ bin/alki-console
my-app> settings.message
=> 'Hello World'
my-app>
Mounting in Assembly
Alki::Console can be mounted into an Alki Assembly. By default it will use the name of the parent assembly (or "app" if it doesn’t have a name) as the prompt, and the parent assembly as the context.
test.rb
require 'alki'
assembly = Alki.create_assembly do
mount :console, 'alki/console'
service :http_client do
require 'net/http'
Net::HTTP
end
end
assembly.new.console.run
$ ruby test.rb
app> http_client.get URI('http://httpbin.org/uuid')
=> "{\n \"uuid\": \"0b6f27a1-bb98-46f5-970d-f5b4fe94f5a7\"\n}\n"