#!/usr/bin/env ruby require "pave.rb" program :name, "Pave" program :version, Pave::VERSION program :description, "Provides a set of command line tools for Concrete5." program :help, "Authors", "Jamon Holmgren , Ryan Linton " default_command :help command :new do |c| c.syntax = "pave new APP_PATH [options]" c.description = "Create a new Concrete5 project." c.action do |args| Pave::Concrete.create(args.first) end end command :update do |c| c.syntax = "pave update" c.description = "Update pave to the latest version." c.action do Pave.update end end command :clean do |c| c.syntax = "pave clean" c.description = "Removes cached files." c.action do Pave.clean end end command :setup do |c| c.syntax = "pave setup APP_PATH" c.description = "Setup folders for project." c.action do |args| name = args.first || Dir.pwd Pave::Concrete.new(name).set_up_folders end end alias_command :"setup:app", :setup command :"setup:git" do |c| c.syntax = "pave setup:git APP_PATH" c.description = "Setup git repo for project." c.action do |args| name = args.first || Dir.pwd Pave::Concrete.new(name).set_up_git end end command :"setup:permissions" do |c| c.syntax = "pave setup:permissions APP_PATH" c.description = "Setup folder permissions for project." c.action do |args| name = args.first || Dir.pwd Pave::Concrete.new(name).modify_folder_permissions end end alias_command :"setup:chmod", :"setup:permissions" command :"setup:clean" do |c| c.syntax = "pave setup:cleanup APP_PATH" c.description = "Remove unused folders from project." c.action do |args| name = args.first || Dir.pwd Pave::Concrete.new(name).remove_extra_folders end end alias_command :"setup:cleanup", :"setup:clean" command :"virtualhost:create" do |c| c.syntax = "pave virtualhost:create VHOST" c.description = "Setup virtual host for Concrete5 project." c.action do |args| host = args.first || "#{File.basename(Dir.pwd)}.site" Pave::VirtualHost.new(host).create_vhost end end alias_command :"vh:create", :"virtualhost:create" command :"virtualhost:remove" do |c| c.syntax = "pave virtualhost:remove VHOST" c.description = "Delete virtual host." c.action do |args| host = args.first || "#{File.basename(Dir.pwd)}.site" Pave::VirtualHost.new(host).remove_vhost end end alias_command :"vh:remove", :"virtualhost:remove" alias_command :"virtualhost:delete", :"virtualhost:remove" alias_command :"vh:delete", :"virtualhost:remove" command :"virtualhost:backup" do |c| c.syntax = "pave virtualhost:backup" c.description = "Back up virtual hosts file. Restore with `pave virtualhost:restore`." c.action do Pave::VirtualHost.new("").backup_vhost end end alias_command :"vh:backup", :"virtualhost:backup" command :"virtualhost:restore" do |c| c.syntax = "pave virtualhost:restore" c.description = "Restore previously backed up virtual hosts file." c.action do Pave::VirtualHost.new("").restore_vhost end end alias_command :"vh:restore", :"virtualhost:restore" command :"virtualhost:restart" do |c| c.syntax = "pave virtualhost:restart" c.description = "Restarts apache." c.action do Pave::VirtualHost.new("").restart_apache end end alias_command :"vh:restart", :"virtualhost:restart" command :"db:create" do |c| c.syntax = "pave db:create DATABASE" c.description = "Create the Concrete5 project's database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.create(name) end end command :"db:drop" do |c| c.syntax = "pave db:drop DATABASE" c.description = "Destroy the Concrete5 project's database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).drop end end command :"db:dump" do |c| c.syntax = "pave db:dump DATABASE" c.description = "Create SQL dump of the project's database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).dump_local end end alias_command :"db:backup", :"db:dump" command :"db:remote:dump" do |c| c.syntax = "pave db:remote:dump DATABASE" c.description = "Create SQL dump of the project's live database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).dump_remote end end alias_command :"db:remote:backup", :"db:remote:dump" command :"db:execute" do |c| c.syntax = "pave db:execute DATABASE" c.description = "Execute SQL dump on the project's database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).execute_remote_dump_on_local_db end end command :"db:remote:execute" do |c| c.syntax = "pave db:remote:execute DATABASE" c.description = "Execute SQL dump on the project's live database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).execute_local_dump_on_remote_db end end command :"db:download" do |c| c.syntax = "pave db:download DATABASE" c.description = "Download SQL dump of the project's live database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).download_remote_to_local end end command :"db:upload" do |c| c.syntax = "pave db:upload DATABASE" c.description = "Upload SQL dump of the project's database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).upload_local_dump_to_remote end end command :"db:pull" do |c| c.syntax = "pave db:pull" c.description = "Download the project's live database and replace local database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).pull end end command :"db:push" do |c| c.syntax = "pave db:push" c.description = "Upload the project's local database and replace the live database." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Database.new(name).push end end command :"files:cache:clear" do |c| c.syntax = "pave cache:clear" c.description = "Empty the project's files/cache and files/tmp directories." c.action do Pave::Files.clear_cache end end alias_command :"cache:clear", :"files:cache:clear" command :"files:pull" do |c| c.syntax = "pave files:pull" c.description = "Download the project's live files directory." c.action do |args| remote = args.first || "live" Pave::Files.pull(remote) end end command :"files:push" do |c| c.syntax = "pave files:push" c.description = "Upload the project's local files directory." c.action do |args| remote = args.first || "live" Pave::Files.push(remote) end end command :"files:sync" do |c| c.syntax = "pave files:sync" c.description = "Syncronize local and remote files directories." c.action do |args| remote = args.first || "live" Pave::Files.sync(remote) end end command :"generate:theme" do |c| c.syntax = "pave generate:theme THEME_NAME" c.description = "Set up a blank theme with sass." c.action do |args| name = args.first || "#{File.basename(Dir.pwd)}" Pave::Theme.create(name) end end alias_command :"g:theme", :"generate:theme" command :watch do |c| c.syntax = "pave watch BROWSER" c.description = "Watch for sass changes." c.action do |args| browser = args.first || "chrome" Pave::Theme.watch(browser) end end command :"deploy" do |c| c.syntax = "pave deploy" c.description = "Deploy project to web server." c.action do |args| remote = args[0] || "live" branch = args[1] || "master" Pave::Remote.deploy(remote, branch) end end command :"deploy:setup" do |c| c.syntax = "pave deploy:setup" c.description = "Setup deployment via git to web server." c.action do Pave::Remote.setup end end command :"livereload" do |c| c.syntax = "pave livereload BROWSER" c.description = "Watch project for changes and refresh page." c.action do |args| browser = args.first || "chrome" Pave::Reload.live_reload(browser) end end