Class: Kontena::Plugin::Shell::ContextTopCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/kontena/plugin/shell/commands/context_top.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #context, #session

Instance Method Summary collapse

Methods inherited from Command

command, completions, description, #has_subcommands?, has_subcommands?, help, #initialize, #run, subcommands

Constructor Details

This class inherits a constructor from Kontena::Plugin::Shell::Command

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/kontena/plugin/shell/commands/context_top.rb', line 10

def execute
  if args[1] && session
    old_context = context.to_a.clone
    context.top
    session.run_command(args[1..-1].join(' '))
    context.concat(old_context) if context.empty?
  else
    context.top
  end
end