Class: SCParse::Script
Overview
A script does not execute a block of code. Rather it loads an existing Ruby script to be executed. Any arguments passed to the script command are passed on to the script being loaded.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Command
Instance Method Summary collapse
- #add_command(command) ⇒ Object
-
#initialize(name, path, execute_prerequisites = true) ⇒ Script
constructor
A new instance of Script.
- #options ⇒ Object
- #options=(options) ⇒ Object
-
#show_help ⇒ Object
Clears out any original arguments passed for the script and instead passes ‘–help’ to the script.
Methods inherited from Command
#execute, #execute_prerequisites?, #has_command?, #has_commands?, #parents, #prerequisites, #scparser, #set_execution_block, #set_prerequisites_block, #usage
Constructor Details
#initialize(name, path, execute_prerequisites = true) ⇒ Script
Returns a new instance of Script.
184 185 186 187 |
# File 'lib/scparse.rb', line 184 def initialize(name, path, execute_prerequisites = true) super(name, execute_prerequisites) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
182 183 184 |
# File 'lib/scparse.rb', line 182 def path @path end |
Instance Method Details
#add_command(command) ⇒ Object
189 190 191 |
# File 'lib/scparse.rb', line 189 def add_command(command) raise TakesNoCommandsError end |
#options ⇒ Object
193 194 195 |
# File 'lib/scparse.rb', line 193 def return nil end |
#options=(options) ⇒ Object
197 198 199 |
# File 'lib/scparse.rb', line 197 def () raise TakesNoOptionsError end |
#show_help ⇒ Object
Clears out any original arguments passed for the script and instead passes ‘–help’ to the script. Hopefully the script knows how to respond to that (hint hint)!
204 205 206 207 208 |
# File 'lib/scparse.rb', line 204 def show_help ARGV.clear ARGV << '--help' load @path end |