Class: Jenkins::CLI::CommandProxy

Inherits:
Object
  • Object
show all
Includes:
Plugin::Proxy
Defined in:
lib/jenkins/cli/command_proxy.rb,
lib/jenkins/cli/command_proxy.rb,
lib/jenkins/cli/command_proxy.rb

Constant Summary collapse

AbortException =
Java.hudson.AbortException

Instance Method Summary collapse

Methods included from Plugin::Proxy

#getTarget, #initialize

Methods included from Plugin::Behavior

extended, #implemented, #included

Methods included from Plugin::Behavior::BehavesAs

#behaves_as

Instance Method Details

#createCloneObject



24
25
26
27
28
# File 'lib/jenkins/cli/command_proxy.rb', line 24

def createClone
  self.dup.tap do |dup|
    dup.instance_variable_set(:@object, @object.dup)
  end
end

#getNameObject

This mirrors what Java.hudson.cli.CLICommand#getName does, but with the @object’s class instead.



32
33
34
# File 'lib/jenkins/cli/command_proxy.rb', line 32

def getName
  @object.class.command_name
end

#getShortDescriptionObject



20
21
22
# File 'lib/jenkins/cli/command_proxy.rb', line 20

def getShortDescription
  @object.class.description
end

#main(args, locale, stdin, stdout, stderr) ⇒ Object

main(List<String> args, Locale locale, InputStream stdin, PrintStream stdout, PrintStream stderr)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/jenkins/cli/command_proxy.rb', line 42

def main(args, locale, stdin, stdout, stderr)
  old_in, old_out, old_err = $stdin, $stdout, $stderr
  begin
    $stdin, $stdout, $stderr = stdin.to_io, stdout.to_io, stderr.to_io
    if @object.parse(args.to_a)
      @object.run
      return 0
    else
      return -1
    end
  rescue AbortException
    return -1
  rescue => e
    $stderr.puts e.full_message
    return -1
  ensure
    $stdin, $stdout, $stderr = old_in, old_out, old_err
  end
end

#runObject

Raises:

  • (RuntimeError)


36
37
38
39
# File 'lib/jenkins/cli/command_proxy.rb', line 36

def run
  # We don't call run from within our main, but needs to be here to satisfy the Java Interface
  raise RuntimeError, "This method should never be called."
end