Module: Gutsy

Defined in:
lib/gutsy.rb,
lib/gutsy/cli.rb,
lib/gutsy/version.rb,
lib/gutsy/generator.rb

Defined Under Namespace

Modules: Cli

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.initialize!Object



12
13
14
15
16
17
18
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gutsy.rb', line 12

def self.initialize!
  args = ARGV

  command = args[0]

  case command
  when "generate"
    unless args.length == 4
      puts "Error: Not enough arguments for command 'generate'\n\nUsage: gutsy generate [app_name] [schema_path] [output_path]\n\nDESCRIPTION\n  Generates a gem scaffold and resource API clients on top of a heroics-generated client.\n\nARGUMENTS\n  [app_name]    - CamelCased name of your application\n  [schema_path] - Path to your JSON Schema file\n  [output_path] - Path to output generated API client gem.\n                  (Will be created if it doesn't exist)\n"
      exit 1
    end
    app_name = args[1]
    schema_path = File.expand_path(args[2])
    output_path = File.expand_path(args[3])

    generator = Gutsy::Cli::Generator.new(app_name, schema_path, output_path)

    begin
      generator.generate!
    rescue => e
      puts "FAIL"
      puts e.message
      puts e.backtrace.join("\n")
      exit 1
    end

    exit 0
  when "version"
    puts "Gutsy version #{Gutsy::VERSION}"
    exit 0
  else
    puts "Usage: gutsy [command] [options]\n\nDESCRIPTION\n  Generates gem wrappers around heroics-generated API clients\n  built with JSON Schema. (Enough layers of generation for ya?)\n\nCOMMANDS\n  generate      scaffolds out an API client\n  version       returns the gutsy version\n  help          displays this message\n\nShouts out Mr. Gutsy. Keep on plugging in the Wasteland.\n    TEXT\n    exit 0\n  end\nend\n"