-
Notifications
You must be signed in to change notification settings - Fork 49
/
generate.exs
64 lines (46 loc) · 1.61 KB
/
generate.exs
1
2
3
4
5
6
7
8
9
10
11
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
language = Enum.at(System.argv, 0)
unless Enum.member?(["elixir", "erlang"], language) do
raise """
Please, specify either elixir or erlang in the first argument:
mix run generate.exs elixir
or, for erlang:
mix run generate.exs erlang
"""
end
spec_path = Enum.at(System.argv, 1, "../aws-sdk-go/models/apis")
if !File.dir?(spec_path) do
raise """
Could not find the specification files under #{spec_path}!
Either specify the correct path in the second argument:
mix run generate.exs #{language} /path/to/aws-sdk-go/models/apis
or clone the AWS SDK with:
git clone [email protected]:aws/aws-sdk-go.git ../aws-sdk-go
and try again.
"""
end
template_path = Enum.at(System.argv, 2, "priv")
if !File.dir?(template_path) do
raise """
Template path "#{template_path}" could not be found!
Please, specify the correct path in the third argument:
mix run generate.exs #{language} #{spec_path} /path/to/template_path
and try again.
"""
end
output_path = Enum.at(System.argv, 3, "../aws-#{language}/lib/aws/generated")
if !File.dir?(output_path) do
raise """
The aws-#{language} project could not be found at path "#{output_path}"!
Please, specify the correct path in the last argument:
mix run generate.exs #{language} #{spec_path} #{template_path} /path/to/aws-#{language}/lib/aws/generated
and try again.
"""
end
IO.puts("""
Generating code with the following parameters:
Language: #{language}
Specification Path: #{spec_path}
Templates Path: #{template_path}
Output Path: #{output_path}
""")
AWS.CodeGen.generate(String.to_atom(language), spec_path, template_path, output_path)