class Capsium::Cli::Reactor
Public Class Methods
# File lib/capsium/cli/reactor.rb, line 41 def self.dispatch(meth, given_args, given_opts, config) super(meth, merge_mount_options(given_args), given_opts && merge_mount_options(given_opts), config) end
Thor array options are last-wins when the flag repeats; collect every –mount value (both “–mount V” and “–mount=V” forms) and re-emit one trailing occurrence so repetition accumulates. (Subcommands are dispatched in-process, so this hooks dispatch, not start; merging is idempotent for the direct-start flow.)
Calls superclass method
Source
# File lib/capsium/cli/reactor.rb, line 46 def self.merge_mount_options(args) values = [] rest = [] index = 0 while index < args.length arg = args[index] if arg == "--mount" index += 1 while index < args.length && !args[index].start_with?("-") values << args[index] index += 1 end elsif arg.start_with?("--mount=") values << arg.split("=", 2).last index += 1 else rest << arg index += 1 end end values.empty? ? args : rest + ["--mount"] + values end
Public Instance Methods
Source
# File lib/capsium/cli/reactor.rb, line 69 def serve(*sources) entries = mount_entries(sources) if entries.empty? raise Thor::Error, "no package source given (positional " \ "arguments, --mount or --config)" end mounts = Capsium::Reactor::Mount.build( entries, store: options[:store], registry: options[:registry] ) reactor = Capsium::Reactor.new( mounts: mounts, port: options[:port], do_not_listen: options[:do_not_listen], store: options[:store], deploy: options[:deploy], registry: options[:registry], workdir: options[:workdir] ) reactor.serve rescue Capsium::Error => e raise Thor::Error, e.message ensure reactor&.cleanup end