root/bin/vintage

Revision 5, 3.0 kB (checked in by jeremymcanal..@gmail.com, 6 months ago)

Fixed little snafu in usage message
Fixed errors in default template

  • Property svn:executable set to
Line 
1 #!/usr/bin/env ruby
2 #
3 #  Created by Jeremy McAnally on 2008-1-1.
4 #  Copyright (c) 2008. All rights reserved.
5
6 $:.unshift File.dirname(__FILE__)
7 require File.dirname(__FILE__) + '/../lib/vintage'
8
9 require 'rubygems'
10 require 'optparse'
11 require 'rubigen'
12
13 # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
14
15 OPTIONS = {
16   :path         => Dir.pwd,
17   :static_path  => Dir.pwd,
18   :port         => 5000,
19   :config       => 'configuration.yml',
20   :templates    => 'erb',
21   :mount        => '/',
22   :root         => 'index',
23   :server       => 'mongrel'
24 }
25 MANDATORY_OPTIONS = %w(  )
26
27 parser = OptionParser.new do |opts|
28   opts.banner = <<BANNER
29  
30 Vintage - v.#{Vintage::VERSION::STRING}
31 =================
32 The super-micro web framework.  If a project name is provided,
33 a new project is generated.  Otherwise, Vintage will start serving
34 given the defaults and/or any provided options.
35
36 Usage: #{File.basename($0)} [options]
37        
38        To generate an application:
39        #{File.basename($0)} [project name]
40        
41        To start your application:
42        #{File.basename($0)} start
43
44 Options are:
45 BANNER
46   opts.separator ""
47   opts.on("-p", "--path=PATH", String,
48           "The root path for selecting files",
49           "Default: ~") { |OPTIONS[:path]| }
50   opts.on("-P", "--port=PORT", Integer,
51           "The port to serve up your Vintage application on",
52           "Default: 5000") { |OPTIONS[:port]| }
53   opts.on("-c", "--config=FILE", String,
54           "The configuration file to use when launching this Vintage application",
55           "Default: configuration.rb") { |OPTIONS[:config]| }
56   opts.on("-t", "--template=TYPE", String,
57           "The parser used for templates (can be erb, haml, mab, markdown, or textile)",
58           "Default: erb") { |OPTIONS[:templates]| }
59   opts.on("-m", "--mount-at=url", String,
60           "The relative URL to mount this application at (e.g., vintage -m myapp will mount at http://localhost/myapp)",
61           "Default: none (mounted at /)") { |OPTIONS[:mount]| }
62   opts.on("-r", "--root=template", String,
63           "The template to render at the root URL",
64           "Default: index") { |OPTIONS[:root]| }
65   opts.on("-s", "--server=server", String,
66           "The server daemon to use (can be mongrel, webrick, cgi, or fastcgi)",
67           "Default: mongrel") { |OPTIONS[:server]| }
68   opts.on("-h", "--help",
69           "Show this help message.") { puts opts; exit }
70   opts.parse!(ARGV)
71 end
72
73 if ARGV.empty?
74   puts parser
75   puts
76 elsif ARGV[0] == "start"
77   if OPTIONS[:server] == 'swift'
78     require 'swiftcore/swiftiplied_mongrel'
79   end
80  
81   OPTIONS.merge!(YAML::load_file(OPTIONS[:config])) if File.exists?(OPTIONS[:config])
82   Vintage::Server.run(OPTIONS)
83 else
84   require 'rubigen/scripts/generate'
85   source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../app_generators"))
86   RubiGen::Base.reset_sources
87   RubiGen::Base.append_sources source
88   RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'vintage_application')
89 end
Note: See TracBrowser for help on using the browser.