Class: Mantle::CLI
- Inherits:
-
Object
- Object
- Mantle::CLI
- Defined in:
- lib/mantle/cli.rb
Instance Method Summary collapse
- #configure_sidekiq ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #listen ⇒ Object
- #load_config ⇒ Object
- #parse_options(args) ⇒ Object
- #setup(args = ARGV) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
9 10 11 |
# File 'lib/mantle/cli.rb', line 9 def initialize @options = {} end |
Instance Method Details
#configure_sidekiq ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mantle/cli.rb', line 48 def configure_sidekiq if namespace = Mantle.configuration.redis_namespace Mantle.logger.info("Configuring Mantle to listen on Redis namespace: #{namespace}") Sidekiq.configure_client do |config| config.redis = { url: ENV["REDIS_URL"], namespace: namespace } end Sidekiq.configure_server do |config| config.redis = { url: ENV["REDIS_URL"], namespace: namespace } end end end |
#listen ⇒ Object
62 63 64 |
# File 'lib/mantle/cli.rb', line 62 def listen Mantle::MessageBus.new.listen end |
#load_config ⇒ Object
42 43 44 45 46 |
# File 'lib/mantle/cli.rb', line 42 def load_config require File.( .fetch :config, './config/initializers/mantle' ) end |
#parse_options(args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mantle/cli.rb', line 19 def (args) optparser = OptionParser.new do |opts| opts. = "Usage: mantle <command> [options]" opts.on("-c", "--config CONFIG_FILE", "Path to configuration file (initializer)") do |arg| [:config] = arg end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts ::Mantle::VERSION exit end end optparser.parse!(args) end |
#setup(args = ARGV) ⇒ Object
13 14 15 16 17 |
# File 'lib/mantle/cli.rb', line 13 def setup(args = ARGV) (args) load_config configure_sidekiq end |