Sha256: b9305bda84ee0db82ee94168a36a8adef29f7f30c7acbc00c5ba882ea4cd8041

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require "fileutils"
require "json"
require "yaml"
require "ostruct"
require "uri"
require "thor"
require "erubis"
require "inquirer"
require "net/http"
require "net/ssh"

require "active_support/dependencies/autoload"
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/hash"
require "active_support/number_helper"

require "vps"
require "vps/core_ext/string"
require "vps/cli/service"
require "vps/cli/upstream"
require "vps/cli/domain"
require "vps/cli/playbook"

module VPS
  class CLI < Thor

    class Error < StandardError; end

    Playbook.all.each do |playbook|
      desc playbook.usage, playbook.description
      method_options playbook.options if playbook.options
      define_method playbook.command do |*args|
        start = Time.now
        playbook.run!(args, options)
        puts "\nDone. ".cyan + "#{(Time.now - start).round(3)}s".gray
      end
    end

    desc "edit [HOST]", "Edit the VPS configuration(s)"
    def edit(host = nil)
      `#{ENV["EDITOR"]} #{VPS.config_path(host, "")}`
    end

    register(Upstream, "upstream", "upstream", "Manage host upstreams")
    register(Service, "service", "service", "Manage host services")
    register(Domain, "domain", "domain", "Manage upstream domains")

    desc "-v, [--version]", "Show VPS version number"
    map %w(-v --version) => :version
    def version
      puts "vps #{VPS::VERSION}"
    end

  private

    def method_missing(method, *_args)
      raise Error, "Unrecognized command \"#{method}\". Please consult `vps help`."
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vps-0.1.1 lib/vps/cli.rb