Sha256: f3a1559febf7b8c68688e0f1cb37ec3d98b9fa7e9e735c9ecf40289252dfbb07

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'thor'
require 'yaml'

module PuppetMagnum
  class Module < Thor

    desc 'create [MODULE_NAME]', 'Creates a new Puppet module.'
    def create(module_name)
      PuppetMagnum::CreateGenerator.new([File.join(Dir.pwd, module_name), module_name], options).invoke_all
    end

    desc 'init [MODULE_NAME]', 'Initializes an existing Puppet module.'
    def init(module_name)
      PuppetMagnum::CreateGenerator.new([File.join(Dir.pwd, module_name), module_name], options).invoke_all
    end

    desc 'verify [MODULE_NAME]', 'Verifies the Puppet module.'
    def verify(module_name)
      PuppetMagnum::Verify.new([File.join(Dir.pwd, module_name), module_name], options).invoke_all
    end

    def self.banner(task, namespace = false, subcommand = true)
      "#{basename} #{task.formatted_usage(self, namespace, subcommand).split(':').join(' ')}"
    end

    private
      def options
        original_options = super

        rcfile = File.expand_path('~/.magnumrc')
        return original_options unless File.exists?(rcfile)

        defaults = ::YAML::load_file(rcfile) || {}
        Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-magnum-4.1.1 lib/puppet-magnum/cli/module.rb
puppet-magnum-4.0.4 lib/puppet-magnum/cli/module.rb
puppet-magnum-4.0.3 lib/puppet-magnum/cli/module.rb
puppet-magnum-4.0.2 lib/puppet-magnum/cli/module.rb