Class: Jarbs::CLI
Constant Summary collapse
- GLOBAL_DEFAULTS =
{ env: 'dev' }
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jarbs.rb', line 19 def initialize @config = Config.new if @config.get('crashes.report') CrashReporter.configure do |c| c.engines = [CrashReporter::GithubIssues.new('articulate/jarbs', @config.get('github.token'))] c.version = Jarbs::VERSION end end end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/jarbs.rb', line 30 def run program :version, Jarbs::VERSION program :description, 'Lambda Tooling' global_option('-e', '--env ENV', String, 'Set deployment environment [Default to dev]') global_option('-d', '--debug', 'Enable debug mode') { $debug = true } command :new do |c| c.syntax = 'jarbs new [options] name' c.summary = "Generate a new lambda function or project skeleton" c.option "-f", "--force", "Force overwrite of existing function definition" c.action do |args, | name = args.shift || abort("Must provide a lambda name") .default GLOBAL_DEFAULTS lambda = Lambda.new(name, ) project_exists?(name, remove: .force) lambda_exists?(lambda, remove: .force) ProjectGenerator.new(name).generate unless jarbs_project? lambda.generate end end command :deploy do |c| c.syntax = 'jarbs deploy [options] directory' c.summary = 'Deploy a lambda function to AWS' c.option "--role [STRING]", String, "IAM role for Lambda execution" c.action do |args, | name = args.shift || abort('Name argument required') .default GLOBAL_DEFAULTS lambda = Lambda.new(name, ) abort("Lambda '#{name}' does not exist.") unless lambda.exists? lambda.deploy end end command :rm do |c| c.syntax = 'jarbs rm NAME [NAME...]' c.summary = "Delete a lambda function" c.action do |args, | abort('Name argument required') if args.empty? .default GLOBAL_DEFAULTS begin args.each do |fn| begin Lambda.new(fn, ).delete rescue Aws::Lambda::Errors::ResourceNotFoundException => e say_error "Function \"#{fn}\" does not exists. Ignoring." next end end end end end command :ls do |c| c.syntax = 'jarbs ls' c.summary = "List lambda functions in this project" c.action do |args, | lambdas = Dir.glob("lambdas/*").map {|x| Lambda.new(File.basename(x), ) } lambdas.each do |l| say "#{l.function.name}: #{l.function.description}" end end end run! end |