Method: Runfile::RunfileHelper#handle

Defined in:
lib/runfile/runfile_helper.rb

#handle(argv) ⇒ Object

Handle the case when run is called without a Runfile present. We will let the user know they can type ‘run new` to create a new sample Runfile. If the first argument matches the name of a *.runfile name, we will return it to the caller. Otherwise, we return false to indicate “no further handling is needed”.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/runfile/runfile_helper.rb', line 19

def handle(argv)
  # make a new runfile
  if argv[0] == "new" && !settings_present?
    make_runfile argv[1]
    return false
  end

  # get a list of *.runfile path-wide
  runfiles = find_runfiles || []

  # if first arg is a valid *.runfile, run it
  if argv[0] 
    runfile = runfiles.select { |f| f[/\/#{argv[0]}.runfile/] }.first
    runfile and return runfile
  end

  # if we are here, offer some help and advice and show a list
  # of possible runfiles to run.
  show_make_help runfiles, settings.folder
  return false
end