Class: FaaStRuby::Command::Workspace::Destroy

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/faastruby/cli/commands/workspace/destroy.rb

Instance Method Summary collapse

Methods inherited from BaseCommand

#has_user_logged_in?, #help, #load_credentials, #load_yaml, #say, spin, #spin, #write_file

Constructor Details

#initialize(args) ⇒ Destroy

Returns a new instance of Destroy.



7
8
9
10
11
12
13
14
15
# File 'lib/faastruby/cli/commands/workspace/destroy.rb', line 7

def initialize(args)
  @args = args
  help
  @missing_args = []
  FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
  @workspace_name = @args.shift
  parse_options
  load_credentials
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/faastruby/cli/commands/workspace/destroy.rb', line 17

def run
  warning unless @options['force']
  FaaStRuby::CLI.error("Cancelled") unless @options['force'] == 'y'
  workspace = FaaStRuby::Workspace.new(name: @workspace_name)
  spinner = spin("Destroying...")
  workspace.destroy
  if workspace.errors.any?
    spinner.error
    FaaStRuby::CLI.error(workspace.errors)
  end
  spinner.success
  puts "Workspace '#{@workspace_name}' was deleted from the cloud platform."
end