I would like to use SSHKit in a Thor script. The problem is that I don't have access to the options variable once I use the SSHKit DSL methods. Has anybody used SSHKit with Thor and been able to access options? / Are there known scoping workarounds with SSHKit?
*Code:*
# Echo.thor
require 'sshkit'
require 'sshkit/dsl'
class Echo < Thor
HOST = SSHKit::Host.new('some_user@some_box')
desc 'echo', 'Simple example'
method_option :echo, desc: 'Thing to echo.'
def echo
# options variable is available here...
puts "options[:echo]: #{options[:echo]}"
on HOST do
# ...but not here.
execute :echo, options[:echo]
end
end
end
*Result:*
>thor echo:echo --echo Timmy
options[:echo]: Timmy
D:/Code/link/scripts/phalanx/echo.thor:15:in `block in echo': undefined
local variable or method `options' for #<SSHKit::Backend::Netssh:0x2e4ef20>
(NameError)
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:54:in
`instance_exec'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:54:in
`run'
from
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sshkit-1.4.0/lib/sshkit/runners/parallel.rb:12:in
`block (2 levels) in execute'
Versions:
- Ruby 2.0.0p353 (Windows 8) and 2.1.1p76 (Mac Mavericks with RbEnv)
- Capistrano N/A
- SSHKit 1.4.0
- Thor 0.19.1 (Windows) and 0.14.6 (Mac)
Platform:
- Tried both Windows 8 and Mac Mavericks.
- Target machine is Ubuntu, but shouldn't be a factor.
--
You received this message because you are subscribed to the Google Groups
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web, visit
https://groups.google.com/d/msgid/capistrano/f692a609-fc7a-44e5-a58f-91e085b19c3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
echo.thor
Description: Binary data
