Class: CDQ::InitAction
Constant Summary
collapse
- HELP_TEXT =
%{Usage:
cdq init [options]
Run inside a motion directory, it will:
* Add cdq and ruby-xcdm to Gemfile, if necessary
* Set rake to automatically run schema:build
* Create an initial schema file
Options:
}
Instance Attribute Summary
Attributes inherited from CommandLine
#singleton_options_passed
Instance Method Summary
collapse
Methods inherited from CommandLine
run_all
Instance Method Details
#option_parser ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/cdq/cli.rb', line 65
def option_parser
super(HELP_TEXT).tap do |opts|
opts.program_name = "cdq init"
opts.on("-d", "--dry-run", "Do a Dry Run") do
@dry_run = "dry_run"
end
end
end
|
#run ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/cdq/cli.rb', line 75
def run
opts = option_parser
opts.order!
unless singleton_options_passed
CDQ::Generator.new(@dry_run).create('init')
print " \u0394 Checking bundle for cdq... "
unless system('bundle show cdq')
print " \u0394 Adding cdq to Gemfile... "
File.open("Gemfile", "at") do |gemfile|
gemfile.puts("gem 'cdq'")
end
puts "Done."
end
print " \u0394 Adding schema:build hook to Rakefile... "
File.open("Rakefile", "at") do |rakefile|
rakefile.puts('task :"build:simulator" => :"schema:build"')
end
puts "Done."
puts %{\n Now edit schemas/0001_initial.rb to define your schema, and you're off and running. }
end
end
|