-
Notifications
You must be signed in to change notification settings - Fork 0
/
acha.rb
61 lines (44 loc) · 1.97 KB
/
acha.rb
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
require "optparse"
load "core_utils/core_utils.rb"
load "files/acha_file.rb"
load "base.rb"
# todo handle missing args
options = {}
repo_url = "https://github.com/foo"
# Eliminate -d flag grab everything after model as args
# For now we are only doing scaffolding, other generators will be added later
opts = OptionParser.new do |opts|
opts.banner = %Q(
~()*~()*~()* ~()*~()*~()* Acha ~()*~()*~()*~()*~()*~()*
~()*~()*~()*~()* MetaProgram Flutter Widgets ~()*~()*~()*~()*
Usage: #{__FILE__} -m [Model] -d [type1:var1 type2:var2]
Model name should be capitalized !!
Typing of Variables should follow Dart syntax !!
** NOTICE **
The generators are not meant to be perfect but do
provide a way to quicky automate the boring stuff and speed
up app development.
For more information visit #{repo_url}.
Feel free to contribute and customize to your hearts desire !\n\n)
opts.on('-m', '--model MyModel', 'The name of the model you would like to use') do |v|
options[:model] = v.downcase.capitalize
end
opts.on('-a', '--attributes type1:var1,type2:var2',
'A list of your models attributes and their types.') do |v|
options[:attrs] = Acha::CoreUtils.parse_data(v.split(","))
end
opts.on('-p', '--path ~/path_to_my_flutter_proj/lib',
'The absolute path to your flutter lib directory') do |v|
options[:path] = v
end
opts.on('-h', '--help', 'Display this screen') {puts opts; exit!}
opts.on_tail "\n\t\t\t\tExample:"
opts.on_tail "\t\t\t\truby #{__FILE__} -m User -a String:name,String:email,int:id\n\n -p absolute_path_of_projects_lib_directory"
end
opts.order!
if options.empty?
puts opts
exit!
end
acha = Acha::Acha.new(options[:model], options[:attrs], options[:path])
acha.generate