Class: FaaStRuby::Command::Workspace::RM

Inherits:
BaseCommand show all
Defined in:
lib/faastruby/cli/commands/workspace/rm.rb

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) ⇒ RM

Returns a new instance of RM.



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

def initialize(args)
  @args = args
  help
  @workspace_name, @relative_path = @args.shift.split(':')
  validate_command
  # FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
  load_credentials
end

Class Method Details

.helpObject



27
28
29
# File 'lib/faastruby/cli/commands/workspace/rm.rb', line 27

def self.help
  "rm WORKSPACE_NAME:/DESTINATION/PATH"
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
# File 'lib/faastruby/cli/commands/workspace/rm.rb', line 16

def run
  # destination_url = "#{FaaStRuby.workspace_host_for(@workspace_name)}/#{@relative_path}"
  spinner = say("[#{@relative_path}] Removing file from cloud workspace '#{@workspace_name}'...")
  workspace = FaaStRuby::Workspace.new(name: @workspace_name)
  workspace.delete_file(relative_path: @relative_path)
  FaaStRuby::CLI.error(workspace.errors) if workspace.errors.any?
  spinner.success
  puts "* [#{@relative_path}] File removed from cloud workspace '#{@workspace_name}'.".green
end

#usageObject



31
32
33
34
# File 'lib/faastruby/cli/commands/workspace/rm.rb', line 31

def usage
  puts "\n# Remove static file from cloud workspace path '/DESTINATION/PATH'."
  puts "\nUsage: faastruby #{self.class.help}\n\n"
end