Class: SCParse::Script

Inherits:
Command show all
Defined in:
lib/scparse.rb

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

Attributes inherited from Command

#commands, #name, #parent

Instance Method Summary collapse

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

#pathObject (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

#optionsObject



193
194
195
# File 'lib/scparse.rb', line 193

def options
  return nil
end

#options=(options) ⇒ Object



197
198
199
# File 'lib/scparse.rb', line 197

def options=(options)
  raise TakesNoOptionsError
end

#show_helpObject

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