Class: FaaStRuby::Command::Project::Down
Class Method Summary
collapse
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) ⇒ Down
Returns a new instance of Down.
10
11
12
13
14
15
16
17
18
|
# File 'lib/faastruby/cli/commands/project/down.rb', line 10
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
|
Class Method Details
.help ⇒ Object
29
30
31
|
# File 'lib/faastruby/cli/commands/project/down.rb', line 29
def self.help
"down [ARGS]"
end
|
Instance Method Details
#parse_options ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/faastruby/cli/commands/project/down.rb', line 47
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
|
#run ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/faastruby/cli/commands/project/down.rb', line 20
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
|
#usage ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/faastruby/cli/commands/project/down.rb', line 33
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
|