bin/sitefuel in sitefuel-0.0.0b vs bin/sitefuel in sitefuel-0.1.0a

- old
+ new

@@ -1,59 +1,87 @@ #!/usr/bin/ruby -wrubygems # == Synopsis # -# A lightweight ruby framework for processing and deploying websites, either -# from +# SiteFuel is a program and lightweight Ruby API for processing the +# source code behind your static and dynamic websites. SiteFuel can +# remove comments and unneeded whitespace from your CSS, HTML, and +# JavaScript files (as well as fragments in RHTML and PHP) files. It can +# also loss-lessly compress your PNG and JPEG images. SiteFuel can also +# deploy your website from SVN or GIT. # +# Support for more file formats and repositories is planned for future +# versions. +# +# # == Usage # -# sitefuel deploy|process SOURCE [OPTIONS] +# sitefuel <command> [--driver=file|svn|git] <source> [<output>] +# [--debug] [--verbose] [--help] [--license] # -# == Introduction -# sitefuel is a lightweight ruby framework for deploying websites directly from -# version control. sitefuel includes support for compressing HTML and CSS as -# well as optimizing PNG graphics. Support is planned for SASS; compressing -# JavaScript; automatically creating sprites; and supporting more image formats. -# (and more!) -# -# TODO: add more details +# === <command> +# Possible commands are: +# stage:: Simulate a deployment of a site. +# deploy:: Deploy a site using SiteFuel. +# help:: Show this message. # -# * More information: http://sitefuel.org -# * Getting started: http://sitefuel.org/getstarted -# * Documentation: http://sitefuel.org/documentation +# === <driver> +# SiteFuel can typically guess what driver to use, but you can explicitly +# specify: # -# == Commands +# filesystem:: deploy a directory +# svn:: use with Subversion repositories +# git:: use with Git repositories # -# deploy:: Deploy a site using sitefuel. -# process:: Modify an existing website inplace. -# stage:: Simulates a deployment without actually changing anything. -# help:: Show this message. +# === <source> +# Specify the source SiteFuel is deploying from. This should accept all +# protocols supported by enabled drivers. Eg. # +# For svn: +# svn+ssh://user@sitefuel.org/svn/web/sitefuel-main +# +# For git: +# ssh://user@sitefuel.org/... +# +# === <output> +# Specify the directory into which SiteFuel is to deploy. Currently SiteFuel can +# only deploy into the file system. +# +# === --debug +# Enables all messages including debugging. This will give you a blow by blow +# account of what SiteFuel is doing. +# +# === --verbose +# Enables most messages. This will give you a relatively detailed account of +# how SiteFuel is deploying your site. +# +# # == Examples # Process an already deployed site: -# sitefuel process /var/www/ +# sitefuel deploy /var/www/sitefuel /var/www/sitefuel-compacted # # Deploy a site from SVN: # sitefuel deploy svn+ssh://sitefuel.org/svn/tags/21 /var/www/ # -# Specify a non-default deployment file: -# sitefuel process /var/www/ -c customdeployment.yml +# == Links # +# * More information: http://sitefuel.org +# * Getting started: http://sitefuel.org/getstarted +# * Documentation: http://sitefuel.org/documentation # # == Author -# Zanoccio, LLC. +# wkm, Zanoccio LLC. # # == Copyright # Copyright (c) 2009 Zanoccio. # # == License # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # stage:: # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # @@ -64,99 +92,24 @@ # add source/ to the load path $:.unshift File.join(File.dirname(__FILE__), "..", "lib") begin - require 'rubygems' -rescue LoadError - # attempt to continue running the program -end - - -require 'rdoc/usage' -require 'term/ansicolor' - -require 'sitefuel/SiteFuelRuntime' - -include Term::ANSIColor - -def puts_and_exit(*args) - puts(*args) - exit -end - -$HELP_HINT_LINE = "type \'#{$0} help\' for usage" - -# parse command line arguments and configure a SiteFuelRuntime -def parse_command_line(runtime) - - #### BUILD THE OPTIONS PARSER - opts = OptionParser.new - - # the banner text comes from the header comment for this file - - opts.on('-oARG', '-o=ARG', '-o PLACE', '--output=ARG', '--output PLACE', String, - 'Where to put a deployed site') do |out| - runtime.deploy_to = out - end - opts.on('-v', '--version', 'Gives the version of sitefuel') do - puts 'SiteFuel ' + VERSION_TEXT - end - - opts.on('--[no-]verbose', 'List actions as they are preformed') do - puts 'cause SiteFuel to be verbose listing actions as they are preformed' - end - - opts.on('--only-list-recognized-files', 'Only list summaries for files which were changed') do - runtime.only_list_recognized_files = true - end - - opts.on('-h', '--help', '-?', '--about', 'Gives help for a specific command.') do - RDoc::usage_no_exit('Synopsis', 'Usage', 'Introduction') - puts opts - RDoc::usage_no_exit('Examples', 'Author', 'Copyright', 'License') - exit - end - - opts.separator '' - opts.separator 'Specific options for a command can be seen with: ' - opts.separator ' COMMAND --help' - - - #### ATTEMPT TO PARSE THE COMMAND LINE begin - commands = opts.parse(*ARGV) - rescue OptionParser::InvalidOption => iopt - puts iopt - puts_and_exit $HELP_HINT_LINE - rescue => exception - # TODO: add better handling for the various exceptions (unnecessary - # argument, missing argument, etc.) - puts_and_exit "couldn't parse command line: #{exception}", $HELP_HINT_LINE + require 'rubygems' + rescue LoadError + # attempt to continue running the program end + require 'sitefuel/SiteFuelRuntime' + require 'sitefuel/CommandLine' - # note that --help will have already been intercepted but 'help' still needs - # special treatment - puts_and_exit 'no command given', $HELP_HINT_LINE if commands.length < 1 - puts_and_exit opts if commands[0].downcase == 'help' - - case commands[0].downcase - when 'deploy' - runtime.deploy_from = commands[1] - runtime.deploy - - when 'stage' - runtime.deploy_from = commands[1] - runtime.stage - - else - puts_and_exit "unknown command: '#{commands[0]}'", $HELP_HINT_LINE + def main + runtime = SiteFuel::SiteFuelRuntime.new + SiteFuel::CommandLine::parse_command_line(runtime) end -end -def main - runtime = SiteFuel::SiteFuelRuntime.new - parse_command_line(runtime) -end + main() -main() +rescue Interrupt + puts 'Fatal: interrupted. Exiting.' +end \ No newline at end of file