Class: FaaStRuby::Command::Function::RemoveFrom
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
#has_user_logged_in?, #help, #load_credentials, #say, spin, #spin, #write_file
Constructor Details
Returns a new instance of RemoveFrom.
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/faastruby/cli/commands/function/remove_from.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_yaml
@function_name = @options['function_name'] || @yaml_config['name']
load_credentials
end
|
Class Method Details
.help ⇒ Object
38
39
40
|
# File 'lib/faastruby/cli/commands/function/remove_from.rb', line 38
def self.help
"remove-from WORKSPACE_NAME [ARGS]"
end
|
Instance Method Details
#load_yaml ⇒ Object
19
20
21
22
|
# File 'lib/faastruby/cli/commands/function/remove_from.rb', line 19
def load_yaml
return true if @options['function_name']
super
end
|
#run ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/faastruby/cli/commands/function/remove_from.rb', line 24
def run
warning unless @options['force']
FaaStRuby::CLI.error("Cancelled") unless @options['force'] == 'y'
spinner = spin("Removing function '#{@function_name}' from workspace '#{@workspace_name}'...")
workspace = FaaStRuby::Workspace.new(name: @workspace_name)
function = FaaStRuby::Function.new(name: @function_name, workspace: workspace)
function.destroy
if function.errors.any?
spinner.error
FaaStRuby::CLI.error(function.errors)
end
spinner.success
end
|
#usage ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/faastruby/cli/commands/function/remove_from.rb', line 42
def usage
puts "\nUsage: faastruby #{self.class.help}"
puts %(
-y,--yes # Don't prompt for confirmation
-f,--function FUNCTION_NAME # Pass the function name instead of attempting
# to read from the function's config file.
)
end
|