Sha256: 3eefcb7420295dc3d0f2d4f84d9093c8ef3a06f56b2ecbb6332d2a3480976db4

Contents?: true

Size: 1.88 KB

Versions: 15

Compression:

Stored size: 1.88 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 %(

Remove a workspace from the cloud.
Must be executed from within a project's directory.

Usage: faastruby #{self.class.help}

-e,--env ENVIRONMENT           # ENVIRONMENT is added to the project's name to compose the workspace name.
                               # Defaults to 'stage'

)
        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.30 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.29 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.28 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.27 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.26 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.25 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.24 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.23 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.22 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.21 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.20 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.19 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.18 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.17 lib/faastruby/cli/commands/project/down.rb
faastruby-0.5.16 lib/faastruby/cli/commands/project/down.rb