Class: Boilerpl8::MainApp
- Inherits:
-
Object
- Object
- Boilerpl8::MainApp
- Defined in:
- lib/boilerpl8.rb
Constant Summary collapse
- COMMAND_OPTIONS =
[ "-h, --help : help", "-v, --version : version", "-B : not append '-boilerpl8' to github repo name", ]
Class Method Summary collapse
Instance Method Summary collapse
- #help_message ⇒ Object
-
#initialize(script_name = nil) ⇒ MainApp
constructor
A new instance of MainApp.
- #run(*args) ⇒ Object
Constructor Details
#initialize(script_name = nil) ⇒ MainApp
Returns a new instance of MainApp.
225 226 227 |
# File 'lib/boilerpl8.rb', line 225 def initialize(script_name=nil) @script_name = script_name || File.basename($0) end |
Class Method Details
.main ⇒ Object
215 216 217 218 219 220 221 222 223 |
# File 'lib/boilerpl8.rb', line 215 def self.main begin self.new.run(*ARGV) exit 0 rescue CommandOptionError => ex $stderr.puts ex. exit 1 end end |
Instance Method Details
#help_message ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/boilerpl8.rb', line 254 def script = @script_name buf = "\#{script} -- download boilerplate files\n\nUsage:\n \#{script} [options] github:<USER>/<REPO> <DIR>\n \#{script} [options] file:<PATH> <DIR>\n\nOptions:\n" COMMAND_OPTIONS.each {|s| buf << " #{s}\n" } buf << "\nExamples:\n\n ## download boilerplate files from github\n $ \#{script} github:kwatch/hello-ruby mygem1 # for ruby\n $ \#{script} github:kwatch/hello-python mypkg1 # for python\n $ \#{script} github:kwatch/keight-ruby myapp1 # for keight.rb\n\n ## '-B' option doesn't append '-boilerpl8' to github repo name\n $ \#{script} -B github:h5bp/html5-boilerplate website1 # for html5\n\n ## expand boilerplate files\n $ \#{script} file:./keight-ruby.tar.gz myapp1\n\n" end |
#run(*args) ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/boilerpl8.rb', line 229 def run(*args) parser = CommandOptionParser.new(COMMAND_OPTIONS) = parser.parse(args) # if ['help'] puts () return 0 end # if ['version'] puts RELEASE return 0 end # boilerplate_name = args[0] # ex: "github:kwatch/hello-ruby" target_dir = args[1] # ex: "mygem1" #; [!eqisx] reports error when boilerplate name or target dir is not specified. boilerplate_name or raise err("#{@script_name}: argument required.") target_dir or raise err("#{@script_name}: target directory name required.") # op = Operation.create(boilerplate_name) op.do_everything(boilerplate_name, target_dir, ) return 0 end |