1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8 <title>Class: MCollective::Applications</title>
10 <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
12 <script src="../js/jquery.js" type="text/javascript"
13 charset="utf-8"></script>
14 <script src="../js/thickbox-compressed.js" type="text/javascript"
15 charset="utf-8"></script>
16 <script src="../js/quicksearch.js" type="text/javascript"
17 charset="utf-8"></script>
18 <script src="../js/darkfish.js" type="text/javascript"
19 charset="utf-8"></script>
25 <div id="file-metadata">
26 <div id="file-list-section" class="section">
27 <h3 class="section-header">In Files</h3>
28 <div class="section-body">
31 <li><a href="../lib/mcollective/applications_rb.html?TB_iframe=true&height=550&width=785"
32 class="thickbox" title="lib/mcollective/applications.rb">lib/mcollective/applications.rb</a></li>
41 <div id="class-metadata">
45 <div id="parent-class-section" class="section">
46 <h3 class="section-header">Parent</h3>
48 <p class="link"><a href="../Object.html">Object</a></p>
53 <!-- Namespace Contents -->
56 <!-- Method Quickref -->
58 <div id="method-list-section" class="section">
59 <h3 class="section-header">Methods</h3>
60 <ul class="link-list">
62 <li><a href="#M000095">::[]</a></li>
64 <li><a href="#M000099">::filter_extra_options</a></li>
66 <li><a href="#M000098">::list</a></li>
68 <li><a href="#M000097">::load_application</a></li>
70 <li><a href="#M000100">::load_config</a></li>
72 <li><a href="#M000096">::run</a></li>
78 <!-- Included Modules -->
82 <div id="project-metadata">
85 <div id="fileindex-section" class="section project-section">
86 <h3 class="section-header">Files</h3>
89 <li class="file"><a href="../COPYING.html">COPYING</a></li>
91 <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
93 <li class="file"><a href="../README.html">README</a></li>
95 <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
97 <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
99 <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
101 <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
103 <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
105 <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
107 <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
109 <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
111 <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
113 <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
115 <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
117 <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
119 <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
121 <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
123 <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
125 <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
127 <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
133 <div id="classindex-section" class="section project-section">
134 <h3 class="section-header">Class Index
135 <span class="search-toggle"><img src="../images/find.png"
136 height="16" width="16" alt="[+]"
137 title="show/hide quicksearch" /></span></h3>
138 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
140 <legend>Quicksearch</legend>
141 <input type="text" name="quicksearch" value=""
142 class="quicksearch-field" />
146 <ul class="link-list">
148 <li><a href="../MCollective.html">MCollective</a></li>
150 <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
152 <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
154 <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
156 <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
158 <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
160 <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
162 <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
164 <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
166 <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
168 <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
170 <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
172 <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
174 <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
176 <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
178 <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
180 <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
182 <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
184 <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
186 <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
188 <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
190 <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
192 <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
194 <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
196 <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
198 <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
200 <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
202 <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
204 <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
206 <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
208 <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
210 <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
212 <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
214 <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
216 <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
218 <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
220 <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
222 <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
224 <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
226 <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
228 <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
230 <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
232 <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
234 <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
236 <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
238 <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
240 <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
242 <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
244 <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
246 <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
248 <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
250 <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
252 <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
254 <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
256 <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
258 <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
260 <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
262 <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
264 <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
266 <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
268 <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
270 <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
272 <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
274 <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
276 <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
278 <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
280 <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
282 <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
284 <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
286 <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
288 <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
290 <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
292 <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
294 <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
296 <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
298 <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
300 <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
302 <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
304 <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
306 <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
308 <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
310 <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
312 <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
314 <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
316 <li><a href="../Array.html">Array</a></li>
318 <li><a href="../Dir.html">Dir</a></li>
320 <li><a href="../Object.html">Object</a></li>
322 <li><a href="../String.html">String</a></li>
324 <li><a href="../Symbol.html">Symbol</a></li>
327 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
334 <div id="documentation">
335 <h1 class="class">MCollective::Applications</h1>
337 <div id="description">
349 <div id="public-class-method-details" class="method-section section">
350 <h3 class="section-header">Public Class Methods</h3>
353 <div id="--method" class="method-detail ">
354 <a name="M000095"></a>
356 <div class="method-heading">
358 <span class="method-name">[]</span><span
359 class="method-args">(appname)</span>
360 <span class="method-click-advice">click to toggle source</span>
364 <div class="method-description">
366 <p class="missing-docs">(Not documented)</p>
370 <div class="method-source-code"
373 <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 3</span>
374 3: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-operator">[]</span>(<span class="ruby-identifier">appname</span>)
375 4: <span class="ruby-identifier">load_application</span>(<span class="ruby-identifier">appname</span>)
376 5: <span class="ruby-constant">PluginManager</span>[<span class="ruby-node">"#{appname}_application"</span>]
377 6: <span class="ruby-keyword kw">end</span></pre>
386 <div id="filter-extra-options-method" class="method-detail ">
387 <a name="M000099"></a>
389 <div class="method-heading">
391 <span class="method-name">filter_extra_options</span><span
392 class="method-args">(opts)</span>
393 <span class="method-click-advice">click to toggle source</span>
397 <div class="method-description">
400 Filters a string of opts out using Shellwords keeping only things related
401 to —config and -c
406 <div class="method-source-code"
407 id="filter-extra-options-source">
409 <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 49</span>
410 49: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">filter_extra_options</span>(<span class="ruby-identifier">opts</span>)
411 50: <span class="ruby-identifier">res</span> = <span class="ruby-value str">""</span>
412 51: <span class="ruby-identifier">words</span> = <span class="ruby-constant">Shellwords</span>.<span class="ruby-identifier">shellwords</span>(<span class="ruby-identifier">opts</span>)
413 52: <span class="ruby-identifier">words</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">word</span>,<span class="ruby-identifier">idx</span><span class="ruby-operator">|</span>
414 53: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"-c"</span>
415 54: <span class="ruby-keyword kw">return</span> <span class="ruby-node">"--config=#{words[idx + 1]}"</span>
416 55: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"--config"</span>
417 56: <span class="ruby-keyword kw">return</span> <span class="ruby-node">"--config=#{words[idx + 1]}"</span>
418 57: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\-c=/</span>
419 58: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">word</span>
420 59: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">word</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\-\-config=/</span>
421 60: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">word</span>
422 61: <span class="ruby-keyword kw">end</span>
423 62: <span class="ruby-keyword kw">end</span>
425 64: <span class="ruby-keyword kw">return</span> <span class="ruby-value str">""</span>
426 65: <span class="ruby-keyword kw">end</span></pre>
435 <div id="list-method" class="method-detail ">
436 <a name="M000098"></a>
438 <div class="method-heading">
440 <span class="method-name">list</span><span
441 class="method-args">()</span>
442 <span class="method-click-advice">click to toggle source</span>
446 <div class="method-description">
449 Returns an array of applications found in the lib dirs
454 <div class="method-source-code"
457 <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 36</span>
458 36: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">list</span>
459 37: <span class="ruby-identifier">load_config</span>
461 39: <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">find</span>(<span class="ruby-value str">"application"</span>)
462 40: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemExit</span>
463 41: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
464 42: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
465 43: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"Failed to generate application list: #{e.class}: #{e}"</span>
466 44: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
467 45: <span class="ruby-keyword kw">end</span></pre>
476 <div id="load-application-method" class="method-detail ">
477 <a name="M000097"></a>
479 <div class="method-heading">
481 <span class="method-name">load_application</span><span
482 class="method-args">(appname)</span>
483 <span class="method-click-advice">click to toggle source</span>
487 <div class="method-description">
489 <p class="missing-docs">(Not documented)</p>
493 <div class="method-source-code"
494 id="load-application-source">
496 <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 26</span>
497 26: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_application</span>(<span class="ruby-identifier">appname</span>)
498 27: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-node">"#{appname}_application"</span>)
500 29: <span class="ruby-identifier">load_config</span>
502 31: <span class="ruby-constant">PluginManager</span>.<span class="ruby-identifier">loadclass</span> <span class="ruby-node">"MCollective::Application::#{appname.capitalize}"</span>
503 32: <span class="ruby-constant">PluginManager</span> <span class="ruby-operator"><<</span> {<span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-node">"#{appname}_application"</span>, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">></span> <span class="ruby-node">"MCollective::Application::#{appname.capitalize}"</span>}
504 33: <span class="ruby-keyword kw">end</span></pre>
513 <div id="load-config-method" class="method-detail ">
514 <a name="M000100"></a>
516 <div class="method-heading">
518 <span class="method-name">load_config</span><span
519 class="method-args">()</span>
520 <span class="method-click-advice">click to toggle source</span>
524 <div class="method-description">
527 We need to know the config file in order to know the libdir so that we can
531 The problem is the CLI might be stuffed with options only the app in the
532 libdir might understand so we have a chicken and egg situation.
535 We’re parsing and filtering MCOLLECTIVE_EXTRA_OPTS removing all but
536 config related options and parsing the options looking just for the config
540 We’re handling failures gracefully and finally restoring the ARG and
541 MCOLLECTIVE_EXTRA_OPTS to the state they were before we started parsing.
544 This is mostly a hack, when we’re redoing how config works this stuff
545 should be made less sucky
550 <div class="method-source-code"
551 id="load-config-source">
553 <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 84</span>
554 84: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">load_config</span>
555 85: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">configured</span>
557 87: <span class="ruby-identifier">original_argv</span> = <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">clone</span>
558 88: <span class="ruby-identifier">original_extra_opts</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">"MCOLLECTIVE_EXTRA_OPTS"</span>].<span class="ruby-identifier">clone</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
559 89: <span class="ruby-identifier">configfile</span> = <span class="ruby-keyword kw">nil</span>
561 91: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>
562 92: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"--config CONFIG"</span>, <span class="ruby-value str">"-c"</span>, <span class="ruby-value str">"Config file"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
563 93: <span class="ruby-identifier">configfile</span> = <span class="ruby-identifier">f</span>
564 94: <span class="ruby-keyword kw">end</span>
566 96: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">program_name</span> = <span class="ruby-identifier">$0</span>
568 98: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"--help"</span>)
570 100: <span class="ruby-comment cmt"># avoid option parsers own internal version handling that sux</span>
571 101: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-v"</span>, <span class="ruby-value str">"--verbose"</span>)
573 103: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">original_extra_opts</span>
574 104: <span class="ruby-keyword kw">begin</span>
575 105: <span class="ruby-comment cmt"># optparse will parse the whole ENV in one go and refuse</span>
576 106: <span class="ruby-comment cmt"># to play along with the retry trick I do below so in</span>
577 107: <span class="ruby-comment cmt"># order to handle unknown options properly I parse out</span>
578 108: <span class="ruby-comment cmt"># only -c and --config deleting everything else and</span>
579 109: <span class="ruby-comment cmt"># then restore the environment variable later when I</span>
580 110: <span class="ruby-comment cmt"># am done with it</span>
581 111: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">"MCOLLECTIVE_EXTRA_OPTS"</span>] = <span class="ruby-identifier">filter_extra_options</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-value str">"MCOLLECTIVE_EXTRA_OPTS"</span>].<span class="ruby-identifier">clone</span>)
582 112: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">environment</span>(<span class="ruby-value str">"MCOLLECTIVE_EXTRA_OPTS"</span>)
583 113: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
584 114: <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">"Failed to parse MCOLLECTIVE_EXTRA_OPTS: #{e}"</span>)
585 115: <span class="ruby-keyword kw">end</span>
587 117: <span class="ruby-constant">ENV</span>[<span class="ruby-value str">"MCOLLECTIVE_EXTRA_OPTS"</span>] = <span class="ruby-identifier">original_extra_opts</span>.<span class="ruby-identifier">clone</span>
588 118: <span class="ruby-keyword kw">end</span>
590 120: <span class="ruby-keyword kw">begin</span>
591 121: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse!</span>
592 122: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
593 123: <span class="ruby-keyword kw">retry</span>
594 124: <span class="ruby-keyword kw">end</span>
596 126: <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">clear</span>
597 127: <span class="ruby-identifier">original_argv</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-constant">ARGV</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">a</span>}
599 129: <span class="ruby-identifier">configfile</span> = <span class="ruby-constant">Util</span>.<span class="ruby-identifier">config_file_for_user</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">configfile</span>
601 131: <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">loadconfig</span>(<span class="ruby-identifier">configfile</span>)
602 132: <span class="ruby-keyword kw">end</span></pre>
611 <div id="run-method" class="method-detail ">
612 <a name="M000096"></a>
614 <div class="method-heading">
616 <span class="method-name">run</span><span
617 class="method-args">(appname)</span>
618 <span class="method-click-advice">click to toggle source</span>
622 <div class="method-description">
624 <p class="missing-docs">(Not documented)</p>
628 <div class="method-source-code"
631 <span class="ruby-comment cmt"># File lib/mcollective/applications.rb, line 8</span>
632 8: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">appname</span>)
633 9: <span class="ruby-identifier">load_config</span>
635 11: <span class="ruby-keyword kw">begin</span>
636 12: <span class="ruby-identifier">load_application</span>(<span class="ruby-identifier">appname</span>)
637 13: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
638 14: <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">colorize</span>(<span class="ruby-identifier">:red</span>, <span class="ruby-value str">" <----"</span>)
639 15: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"Application '#{appname}' failed to load:"</span>
640 16: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span>
641 17: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">colorize</span>(<span class="ruby-identifier">:red</span>, <span class="ruby-node">" #{e} (#{e.class})"</span>)
642 18: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span>
643 19: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">" %s"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n "</span>)]
644 20: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
645 21: <span class="ruby-keyword kw">end</span>
647 23: <span class="ruby-constant">PluginManager</span>[<span class="ruby-node">"#{appname}_application"</span>].<span class="ruby-identifier">run</span>
648 24: <span class="ruby-keyword kw">end</span></pre>
663 <div id="rdoc-debugging-section-dump" class="debugging-section">
665 <p>Disabled; run with --debug to generate this.</p>
669 <div id="validator-badges">
670 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
671 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
672 Rdoc Generator</a> 1.1.6</small>.</p>