Sha256: 1675db368ee41bc76a0b4ba2ede1d7d24b54722f4d37d52aea195eed930ca397

Contents?: true

Size: 1.76 KB

Versions: 15

Compression:

Stored size: 1.76 KB

Contents

require 'open3'
module FaaStRuby
  module Command
    STDOUT_MUTEX = Mutex.new
    module Project
      require 'faastruby/cli/commands/project/base_command'
      require 'faastruby/server/logger'
      class Down < ProjectBaseCommand
        extend FaaStRuby::Logger
        def initialize(args)
          @args = args
          help
          parse_options
          @options['environment'] ||= 'stage'
          @project_yaml = YAML.load(File.read(PROJECT_YAML_FILE))['project'] rescue FaaStRuby::CLI.error("Could not find file 'project.yml'. Are you running this command from the project's folder?")
          @project_name = @project_yaml['name']
          @project_identifier = "-#{@project_yaml['identifier']}" if @project_yaml['identifier']
        end

        def run
          workspace = "#{@project_name}-#{@options['environment']}#{@project_identifier}"
          if @options['force']
            exec("faastruby destroy-workspace #{workspace} -y")
          else
            exec("faastruby destroy-workspace #{workspace}")
          end
        end

        def self.help
          "down [ARGS]"
        end

        def usage
          puts "Usage: faastruby #{self.class.help}"
          puts %(
-e,--env ENVIRONMENT           # ENVIRONMENT is added to the project name to compose the workspace name.
          )
        end

        def parse_options
          @options = {'functions' => []}
          while @args.any?
            option = @args.shift
            case option
            when '-y', '--yes'
              @options['force'] = true
            when '--env', '-e'
              @options['environment'] = @args.shift
            else
              FaaStRuby::CLI.error("Unknown argument: #{option}")
            end
          end
        end

      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
faastruby-0.5.15 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.14 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.13 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.12 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.11 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.10 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.9 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.8 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.7 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.6 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.5 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.4 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.3 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.2 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.0 lib/faastruby/cli/commands/project/down.rb