Class: Kontena::Plugin::Shell::EnvCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/kontena/plugin/shell/commands/env.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



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kontena/plugin/shell/commands/env.rb', line 13

def execute
  if args[1] && args[1].include?('=')
    var, val = args[1].split('=', 2)
    ENV[var]=val
    Kontena::Cli::Config.reset_instance
  elsif args[1]
    puts ENV[args[1]]
  else
    puts ENV.map {|k,v| "#{k}=#{v}"}.join("\n")
  end
end