Class: Textus::CLI::Verb::HookRun
- Inherits:
-
Textus::CLI::Verb
- Object
- Textus::CLI::Verb
- Textus::CLI::Verb::HookRun
- Defined in:
- lib/textus/cli/verb/hook_run.rb
Instance Attribute Summary
Attributes inherited from Textus::CLI::Verb
Instance Method Summary collapse
Methods inherited from Textus::CLI::Verb
command_name, #context_for, descendants, #emit, inherited, #initialize, needs_store?, #operations_for, option, options, parent_group, #resolved_role
Constructor Details
This class inherits a constructor from Textus::CLI::Verb
Instance Method Details
#call(store) ⇒ Object
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 44 45 46 47 |
# File 'lib/textus/cli/verb/hook_run.rb', line 12 def call(store) name = @raw_argv.shift raise UsageError.new("hook run requires a name") if name.nil? as_flag = nil args = {} @raw_argv.each do |tok| case tok when /\A--as=(.+)\z/ then as_flag = ::Regexp.last_match(1) when /\A--output=/ then next when /\A--format=/ then raise FlagRenamed.new("--format", "--output") when /\A--([\w-]+)=(.*)\z/ then args[::Regexp.last_match(1)] = ::Regexp.last_match(2) else raise UsageError.new("unknown arg to 'hook run #{name}': #{tok}") end end Role.resolve(flag: as_flag, env: ENV, root: store.root) callable = store.bus.rpc_callable(:resolve_intake, name) begin Timeout.timeout(Textus::Application::Refresh::Worker::FETCH_TIMEOUT_SECONDS) do callable.call(config: {}, store: store, args: args) end rescue Timeout::Error raise UsageError.new( "hook run '#{name}' exceeded #{Textus::Application::Refresh::Worker::FETCH_TIMEOUT_SECONDS}s timeout", ) rescue Textus::Error raise rescue StandardError => e raise UsageError.new("hook run '#{name}' raised: #{e.class}: #{e.}") end emit({ "action" => name, "ok" => true }) end |
#parse(argv) ⇒ Object
8 9 10 |
# File 'lib/textus/cli/verb/hook_run.rb', line 8 def parse(argv) @raw_argv = argv end |