Sha256: e40a76067287fd00ade45c6b3a74de4790fc76924dfa79b1e486ab6581fe2b62

Contents?: true

Size: 1.48 KB

Versions: 20

Compression:

Stored size: 1.48 KB

Contents

require 'itamae'
require 'thor'

module Itamae
  class CLI < Thor
    class_option :log_level, type: :string, aliases: ['-l'], default: 'info'
    class_option :color, type: :boolean, default: true

    def initialize(*args)
      super

      Itamae::Logger.level = ::Logger.const_get(options[:log_level].upcase)
      Itamae::Logger.formatter.colored = options[:color]
    end

    desc "local RECIPE [RECIPE...]", "Run Itamae locally"
    option :node_json, type: :string, aliases: ['-j']
    option :dry_run, type: :boolean, aliases: ['-n']
    option :ohai, type: :boolean, default: false
    def local(*recipe_files)
      if recipe_files.empty?
        raise "Please specify recipe files."
      end

      Runner.run(recipe_files, :local, options)
    end

    desc "ssh RECIPE [RECIPE...]", "Run Itamae via ssh"
    option :node_json, type: :string, aliases: ['-j']
    option :dry_run, type: :boolean, aliases: ['-n']
    option :host, required: true, type: :string, aliases: ['-h']
    option :user, type: :string, aliases: ['-u']
    option :key, type: :string, aliases: ['-i']
    option :port, type: :numeric, aliases: ['-p']
    option :ohai, type: :boolean, default: false
    option :vagrant, type: :boolean, default: false
    def ssh(*recipe_files)
      if recipe_files.empty?
        raise "Please specify recipe files."
      end

      Runner.run(recipe_files, :ssh, options)
    end

    desc "version", "Print version"
    def version
      puts "Itamae v#{Itamae::VERSION}"
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
itamae-1.0.3 lib/itamae/cli.rb
itamae-1.0.2 lib/itamae/cli.rb
itamae-1.0.1 lib/itamae/cli.rb
itamae-1.0.0 lib/itamae/cli.rb
itamae-1.0.0.beta50 lib/itamae/cli.rb
itamae-1.0.0.beta49 lib/itamae/cli.rb
itamae-1.0.0.beta48 lib/itamae/cli.rb
itamae-1.0.0.beta47 lib/itamae/cli.rb
itamae-1.0.0.beta46 lib/itamae/cli.rb
itamae-1.0.0.beta45 lib/itamae/cli.rb
itamae-1.0.0.beta44 lib/itamae/cli.rb
itamae-1.0.0.beta43 lib/itamae/cli.rb
itamae-1.0.0.beta42 lib/itamae/cli.rb
itamae-1.0.0.beta41 lib/itamae/cli.rb
itamae-1.0.0.beta40 lib/itamae/cli.rb
itamae-1.0.0.beta39 lib/itamae/cli.rb
itamae-1.0.0.beta38 lib/itamae/cli.rb
itamae-1.0.0.beta37 lib/itamae/cli.rb
itamae-1.0.0.beta36 lib/itamae/cli.rb
itamae-1.0.0.beta35 lib/itamae/cli.rb