Class: Appifier::CLI::Subcommands::Datasets

Inherits:
Thor
  • Object
show all
Defined in:
lib/appifier/cli/datasets.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Datasets

Returns a new instance of Datasets.



7
8
9
10
11
# File 'lib/appifier/cli/datasets.rb', line 7

def initialize(*args)
  super
  @output = Carioca::Registry.get.get_service name: :output
  @finisher = Carioca::Registry.get.get_service name: :finisher
end

Instance Method Details

#lsObject



15
16
17
18
19
20
21
22
23
# File 'lib/appifier/cli/datasets.rb', line 15

def ls
  begin
      Appifier::Components::Dataset::list
      @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
      @output.error e.message
      @finisher.terminate exit_case: :error_exit
  end 
end

#pruneObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/appifier/cli/datasets.rb', line 57

def prune
  begin
      ok = (options[:force]) ?  true : TTY::Prompt.new.yes?("Do you want to prune datasets?")
      if ok
          Appifier::Components::Dataset::prune
          @finisher.terminate exit_case: :quiet_exit
      else
          puts "Pruning cancelled"
          @finisher.terminate exit_case: :quiet_exit
      end
  rescue TTY::Reader::InputInterrupt
      @output.warn "Command interrupted"
      @finisher.terminate exit_case: :interrupt
  end   
end

#rm(dataset) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/appifier/cli/datasets.rb', line 39

def rm(dataset)
   begin 
       Appifier::Components::Dataset::rm(dataset)
        @finisher.terminate exit_case: :quiet_exit
   rescue RuntimeError => e
       @output.error e.message
       @finisher.terminate exit_case: :error_exit
   end 
end

#show(dataset) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/appifier/cli/datasets.rb', line 27

def show(dataset)
  begin
      Appifier::Components::Dataset::show dataset
      @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
      @output.error e.message
      @finisher.terminate exit_case: :error_exit
  end 
end