Sha256: 6111c2516eec85d7f24f3618947d362edc366f08a9bd46a99a7fd30ea681f1c1

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

#!/usr/bin/env ruby

require "thor"
require File.expand_path("../../lib/thincloud/deployment/version", __FILE__)

module Thincloud
  module Deployment
    class CLI < ::Thor
      include ::Thor::Actions

      desc "version", "Show the thincloud-deployment version"
      def version
        say gem_version
      end

      desc "list", "List recipes included in thincloud-deployment"
      def list
        say "Recipes included in thincloud-deployment (v#{gem_version}):"
        say ""
        print_table recipes.map { |r| ["*", r] }, indent: 2
        say ""
      end

      desc "show RECIPE", "Show the contents of a specific recipe"
      def show(recipe)
        path = File.expand_path("#{source_root}/#{recipe}.rb")
        found = recipe_paths.grep(%r{#{path}}).first
        say "Recipe `#{recipe}` not found." and return unless found

        say ""
        say "-- Recipe: #{recipe} --"
        say ""
        say File.read(found).strip
        say ""
        say "-- END OF LINE --"
      end

      private

      def source_root
        path = "../../lib/thincloud/recipes"
        self.class.source_root File.expand_path(path, __FILE__)
      end

      def recipe_paths
        Dir[File.expand_path("#{source_root}/*.rb", __FILE__)]
      end

      def recipes
        recipe_paths.map { |recipe| File.basename(recipe, ".rb") }
      end

      def gem_version
        Thincloud::Deployment::VERSION
      end
    end
  end
end

Thincloud::Deployment::CLI.start

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thincloud-deployment-1.0.1 bin/thincloud-deployment
thincloud-deployment-1.0.0 bin/thincloud-deployment