Class: RailsSkeleton::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-skeleton/cli.rb

Overview

CLI is the Command-Line Interface class. This class parses the arguments from the command line

Class Method Summary collapse

Class Method Details

.execute(stdout, arguments = []) ⇒ Object

Reads parameters from arguments and fires up the Botify::Client.

Parameters:

stdout

Where to send output

arguments

The arguments to parse



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rails-skeleton/cli.rb', line 19

def self.execute(stdout, arguments=[])

  # NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
  repos = RailsSkeleton::DEFAULT_SKELETON_REPOSITORY
  mandatory_options = %w(  )

  parser = OptionParser.new do |opts|
    opts.banner = "      RailsSkeleton -- Get that skeleton out of the closet\n\n      Usage: \#{File.basename($0)} APP_NAME branch [options]\n\n      Options are:\n    BANNER\n    opts.separator \"\"\n    opts.on(\"-r\", \"--repos=URL\", String,  \"Skeleton repository URL [\#{repos}]\")  { |arg| repos = arg }\n    opts.on(\"-h\", \"--help\",    \"Show this help message.\")                        { stdout.puts opts; exit }\n    opts.on(\"-v\", \"--version\", \"Show version.\")                                  { stdout.puts \"RailsSkeleton version \#{RailsSkeleton::VERSION}\"; exit }\n    \n    opts.parse!(arguments)\n\n    if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }\n      stdout.puts opts; exit\n    end\n  end\n  \n\n  name   = ARGV[0]\n  branch = ARGV[1]\n\n  unless name && branch\n    puts parser.to_s\n    exit\n  end\n\n  app = RailsSkeleton::Client.new(name, branch, repos)\n  app.lolcats\nend\n".gsub(/^          /,'')