#!/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}" puts "Running #{command}..." end exec(dokku_command) end # backup:export [file] Export dokku configuration files # backup:import [file] Import dokku configuration files # config Display the config vars for an app # config:get KEY Display a config value for an app # config:set KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars # config:unset KEY1 [KEY2 ...] Unset one or more config vars # create Create an app # delete Delete an application # domains Display the domains for an app # domains:set DOMAIN1 [DOMAIN2 ...] Set one or more domains # help Print the list of commands # logs [-t] Show the last logs for an application (-t follows) # plugins-install Install active plugins # plugins Print active plugins # postgres:console Open a PostgreSQL console # postgres:create Create a PostgreSQL container # postgres:delete Delete specified PostgreSQL container # postgres:dump > dump_file.sql Dump database data # postgres:info Display database informations # postgres:link Link an app to a PostgreSQL database # postgres:list Display list of PostgreSQL containers # postgres:logs Display last logs from PostgreSQL container # postgres:restore < dump_file.sql Restore database data from a previous dump # redis:create Create a Redis container # redis:delete Delete specified Redis container # redis:info Display container information # redis:link Link an app to a Redis container # redis:logs Display last logs from Redis container # run Run a command in the environment of an application # url Show the URL for an application # version Print dokku's version # supplemental methods here # Declare command-line interface here # description "one line description of your app" # # 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