Class: Jenkins2::CLI
- Inherits:
-
Object
- Object
- Jenkins2::CLI
- Defined in:
- lib/jenkins2/cli.rb,
lib/jenkins2/cli/job.rb,
lib/jenkins2/cli/root.rb,
lib/jenkins2/cli/user.rb,
lib/jenkins2/cli/view.rb,
lib/jenkins2/cli/nodes.rb,
lib/jenkins2/cli/plugins.rb,
lib/jenkins2/cli/credentials.rb,
lib/jenkins2/cli/role_strategy.rb
Direct Known Subclasses
AddJobToView, AssignRole, CancelQuietDown, ConnectNode, CopyJob, CreateCredentialsByXml, CreateCredentialsDomainByXml, CreateJob, CreateNode, CreateRole, CreateView, DeleteCredentials, DeleteCredentialsDomain, DeleteJob, DeleteNode, DeleteRoles, DeleteView, DisableJob, DisconnectNode, EnableJob, GetCredentialsAsXml, GetCredentialsDomainAsXml, GetJob, GetNode, GetView, InstallPlugin, ListCredentials, ListJobs, ListNode, ListOnlineNode, ListPlugins, ListRoles, OfflineNode, OnlineNode, QuietDown, RemoveJobFromView, Restart, SafeRestart, ShowPlugin, UnassignAllRoles, UnassignRole, UninstallPlugin, UpdateCredentialsByXml, UpdateCredentialsDomainByXml, UpdateJob, UpdateNode, UpdateView, Version, WaitNodeOffline, WaitNodeOnline, WhoAmI
Defined Under Namespace
Classes: AddJobToView, AssignRole, CancelQuietDown, ConnectNode, CopyJob, CreateCredentialsByXml, CreateCredentialsDomainByXml, CreateJob, CreateNode, CreateRole, CreateView, DeleteCredentials, DeleteCredentialsDomain, DeleteJob, DeleteNode, DeleteRoles, DeleteView, DisableJob, DisconnectNode, EnableJob, GetCredentialsAsXml, GetCredentialsDomainAsXml, GetJob, GetNode, GetView, InstallPlugin, ListCredentials, ListJobs, ListNode, ListOnlineNode, ListPlugins, ListRoles, OfflineNode, OnlineNode, QuietDown, RemoveJobFromView, Restart, SafeRestart, ShowPlugin, UnassignAllRoles, UnassignRole, UninstallPlugin, UpdateCredentialsByXml, UpdateCredentialsDomainByXml, UpdateJob, UpdateNode, UpdateView, Version, WaitNodeOffline, WaitNodeOnline, WhoAmI
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .class_to_command ⇒ Object
-
.description ⇒ Object
This method should be overwritten in subclasses.
- .subcommands ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options = {}) ⇒ CLI
constructor
A new instance of CLI.
- #parse(args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CLI
Returns a new instance of CLI.
20 21 22 23 24 25 26 |
# File 'lib/jenkins2/cli.rb', line 20 def initialize(={}) @options = .dup @command = [] @errors = [] @parser = nil end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
18 19 20 |
# File 'lib/jenkins2/cli.rb', line 18 def errors @errors end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/jenkins2/cli.rb', line 18 def @options end |
Class Method Details
.class_to_command ⇒ Object
54 55 56 |
# File 'lib/jenkins2/cli.rb', line 54 def self.class_to_command to_s.split('::').last.gsub(/(.)([A-Z])/, '\1-\2').downcase if superclass == Jenkins2::CLI end |
.description ⇒ Object
This method should be overwritten in subclasses
52 |
# File 'lib/jenkins2/cli.rb', line 52 def self.description; end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jenkins2/cli.rb', line 28 def call if [:help] summary elsif [:version] Jenkins2::VERSION elsif !errors.empty? errors.join("\n") + "\n" + summary else run end end |
#parse(args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jenkins2/cli.rb', line 40 def parse(args) parser.order! args do |nonopt| @command << nonopt return command_to_class.new().parse(args) if command_to_class next end missing = mandatory_arguments.select{|a| [a].nil? } @errors << "Missing argument(s): #{missing.join(', ')}." unless missing.empty? self end |