Method: Consular::DSL#tab

Defined in:
lib/consular/dsl.rb

#tab(*args, &block) ⇒ Object

Run commands in the context of a tab.

Examples:

tab 'first tab', :settings => 'Grass' do
  run 'ps aux'
end

tab 'ls', 'gitx'

Parameters:

  • args (Array)

    Accepts either:

    - an array of string commands
    - a hash containing options for the tab.
    
  • block (Proc)


122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/consular/dsl.rb', line 122

def tab(*args, &block)
  tabs = @_context[:tabs]
  key  = "tab#{tabs.keys.size}"
  return (tabs[key] = { :commands => args }) unless block_given?

  context           = (tabs[key] = {:commands => []})
  options           = args.extract_options!
  options[:name]    = args.first unless args.empty?
  context[:options] = options

  run_context context, &block
  @_context = @_windows[@_windows.keys.last] # Jump back out into the context of the last window.
end