#!/usr/bin/env ruby require 'optparse' require 'methadone' require 'pave.rb' class App include Methadone::Main include Methadone::CLILogging include Methadone::SH main do |command, opt| # Add args you want: |like,so| # your program code here # You can access CLI options via # the options Hash info "pave - Command line tools for Concrete5." info "By Jamon Holmgren" case command.to_sym when :new then Pave::Concrete.create(opt) when :update then update_gem when :help then show_help when :virtualhost then info "`virtualhost` command not implemented yet." when :dbcreate then info "`dbcreate` command not implemented yet." when :db then info "`db` command not implemented yet." when :version then info "pave version #{Pave::VERSION} - by Jamon Holmgren" else show_help end 0 # Good! end def self.update_gem sh "gem update pave" end def self.show_help info "Commands:" info " new " info " Downloads and configures a new Concrete5 website." info " update" info " Updates the pave gem to the latest version." info "" info "Future commands (not implemented yet):" info " virtualhost " info " Sets up a new virtualhost on Apache, pointing to the current folder." info " dbcreate " info " Sets up a new database on the local MySQL instance." info " db dump" info " Dumps the current database to a local file." info " db download" info " Downloads the remote database and replaces the local database with it." info " db upload" info " Uploads the local database to the remote one, replacing what's there." end def self.create(name) info "Creating #{name}..." sleep 2 info "Done." end # supplemental methods here # Declare command-line interface here description "Command line for Concrete5 websites." # # Accept flags via: # on("--flag VAL","Some flag") # options[flag] will contain VAL # # Specify switches via: # on("--[no-]switch","Some switch") # # Or, just call OptionParser methods on opts # # Require an argument arg :command # # # Make an argument optional arg :opt, :optional version Pave::VERSION use_log_level_option go! end