Sha256: 850b3ef8fbdda362ef86f87f678d4898590861e819951e6cfc0b20628e969a78

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require 'hanzo/modules/deploy'
require 'hanzo/modules/diff'
require 'hanzo/modules/install'
require 'hanzo/modules/config'

module Hanzo
  class CLI < Base
    def run
      @options.parse!(@args) if @opts.respond_to? :parse!
      puts @options unless @options.to_s == "Usage: hanzo [options]\n"
    end

  protected

    def initialize_variables
      @app = extract_argument(0)
    end

    def initialize_cli
      initialize_help && return if @app.nil?

      begin
        @options = Hanzo.const_get(@app.capitalize).new(@args).options
      rescue NameError
        initialize_help
      end
    end

    def initialize_help
      @options.banner = <<-BANNER.unindent
        Usage: hanzo action [options]

        Available actions:
           deploy - Deploy a branch or a tag
             diff - Show the diff between HEAD and the current release
          install - Install Hanzo configuration
           config - Manage Heroku configuration variables

        Options:
      BANNER
      @options.on('-h', '--help', 'You\'re looking at it.') { puts @options }
      @options.on('-v', '--version', 'Print version') { puts "Hanzo #{Hanzo::VERSION}" }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanzo-1.0.0 lib/hanzo/cli.rb
hanzo-0.6.2 lib/hanzo/cli.rb
hanzo-0.6.1 lib/hanzo/cli.rb
hanzo-0.6 lib/hanzo/cli.rb
hanzo-0.5 lib/hanzo/cli.rb
hanzo-0.4.5 lib/hanzo/cli.rb