Sha256: 17f8ec4c66125a57d64a649b024008c653c2a7eab52d7e243be6a7d52ee59932
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
# Copyright (c) The Cocktail Experience S.L. (2016) require "thor" require_relative "aws_function" module Tck module Lambdas class CLI < Thor include Thor::Actions def self.source_root File.dirname(__FILE__) end desc "all", "List all AWS Lambdas currently available in tck-lambdas." def all puts "Available functions in tck-lambdas:" Dir["#{CLI.source_root}/*/source"].map do |dir| puts " - #{dir.match(/lambdas\/(.*)\/source/)[1]}" end end desc "used", "List functions currently used by this project." def used puts "Functions currently used by this project:" if yaml = Tck::Lambdas::AwsFunction.yaml yaml.each do |lambda_name, properties| puts " - #{properties["function-name"]} (cloned from '#{lambda_name}')" end else puts "No lambdas found in this directory... :(" end end map list: :used desc "use NAME", "Use the AWS Lambda function known as NAME at The Cocktail." def use(name) puts "#{CLI.source_root}/#{name}" if File.directory?("#{CLI.source_root}/#{name}") @lambda = Tck::Lambdas::AwsFunction.new(name) copy_file "Rakefile" copy_file "Gemfile.example" template "templates/lambdas.yml.erb", ".lambdas.yml" template "templates/lambdas.rake.erb", "lib/tasks/lambdas.rake" copy_file "aws_function.rb", "lib/tck/lambdas/aws_function.rb" copy_file "test.rb", "lambdas/test.rb" directory name, "lambdas/#{name}" else raise "Sorry, '#{name}' is not a valid lambda name." end end desc "roles", "List current AWS IAM roles (running 'aws iam list-roles [...]')." def roles cmd = 'aws iam list-roles --query "Roles[].[RoleName,Arn]"' puts cmd puts `#{cmd}` end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tck-lambdas-0.3.5 | lib/tck/lambdas/cli.rb |
tck-lambdas-0.3.4 | lib/tck/lambdas/cli.rb |
tck-lambdas-0.3.3 | lib/tck/lambdas/cli.rb |