Class: Retscli::ShellCommands

Inherits:
Thor
  • Object
show all
Defined in:
lib/retscli/shell_commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options, config) ⇒ ShellCommands

Returns a new instance of ShellCommands.



5
6
7
8
# File 'lib/retscli/shell_commands.rb', line 5

def initialize(args, options, config)
  super
  @display_adapter = config[:display_adapter]
end

Class Method Details

since we are using thor for shell commands we want to remove executable name from command help menu



12
13
14
# File 'lib/retscli/shell_commands.rb', line 12

def self.banner(command, namespace = nil, subcommand = false)
  super.gsub("#{basename} ", "")
end

.command_listObject



16
17
18
# File 'lib/retscli/shell_commands.rb', line 16

def self.command_list
  all_commands.keys.map{ |command| command.gsub('_', '-') }
end

Instance Method Details

#capabilitiesObject



21
22
23
# File 'lib/retscli/shell_commands.rb', line 21

def capabilities
  @display_adapter.page(@display_adapter.capabilities)
end

#classes(resource) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/retscli/shell_commands.rb', line 37

def classes(resource)
  if options[:editor]
    @display_adapter.open_in_editor(@display_adapter.classes(resource), options[:editor])
  else
    @display_adapter.page(@display_adapter.classes(resource))
  end
end

#metadataObject



74
75
76
77
78
79
80
# File 'lib/retscli/shell_commands.rb', line 74

def 
  if options[:editor]
    @display_adapter.open_in_editor(@display_adapter., options[:editor])
  else
    @display_adapter.page(@display_adapter.)
  end
end

#objects(resource) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/retscli/shell_commands.rb', line 57

def objects(resource)
  if options[:editor]
    @display_adapter.open_in_editor(@display_adapter.objects(resource), options[:editor])
  else
    @display_adapter.page(@display_adapter.objects(resource))
  end
end

#resourcesObject



27
28
29
30
31
32
33
# File 'lib/retscli/shell_commands.rb', line 27

def resources
  if options[:editor]
    @display_adapter.open_in_editor(@display_adapter.resources, options[:editor])
  else
    @display_adapter.page(@display_adapter.resources)
  end
end

#search_metadata(search) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/retscli/shell_commands.rb', line 86

def (search)
  search_options = {
    :classes => options[:classes],
    :resources => options[:resources]
  }

  if options[:editor]
    @display_adapter.open_in_editor(@display_adapter.(search, search_options.merge(:color => false)), options[:editor])
  else
    @display_adapter.page(@display_adapter.(search, search_options))
  end
end

#tables(resource, klass) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/retscli/shell_commands.rb', line 47

def tables(resource, klass)
  if options[:editor]
    @display_adapter.open_in_editor(@display_adapter.tables(resource, klass), options[:editor])
  else
    @display_adapter.page(@display_adapter.tables(resource, klass))
  end
end

#timezone_offsetObject



66
67
68
# File 'lib/retscli/shell_commands.rb', line 66

def timezone_offset
  puts @display_adapter.timezone_offset
end