#!/usr/bin/env ruby require "optparse" require "methadone" require "dokku_installer_cli.rb" class App include Methadone::Main include Methadone::CLILogging main do |command, *args| git_config = File.join(Dir.pwd, ".git", "config") exit unless File.exist?(git_config) git_config = File.read(git_config) match = git_config.match(/url \= dokku@(.*):(.*)\n/).to_a exit unless match domain = match[1] app_name = match[2] dokku_command = "ssh -t dokku@#{domain} " case command when "config" dokku_command += "config #{app_name}" when "config:get" dokku_command += "config:get #{app_name} #{args.first}" when "config:set" dokku_command += "config:set #{app_name} #{args.join(' ')}" when "config:unset" dokku_command += "config:unset #{app_name} #{args.join(' ')}" when "create" dokku_command += "create #{args.first}" when "domains" dokku_command += "domains #{app_name}" when "domains:set" dokku_command += "domains:set #{app_name} #{args.join(' ')}" when "logs" dokku_command += "logs #{app_name} #{args.join(' ')}" when "run" command = args.join(" ") dokku_command += "run #{app_name} #{command}" else exit end puts "Running #{dokku_command}..." exec(dokku_command) end description "Command line tool for Dokku Installer" arg :command # # 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 :some_arg # # # Make an argument optional # arg :optional_arg, :optional version DokkuInstallerCli::VERSION use_log_level_option :toggle_debug_on_signal => "USR1" go! end