Class: Retscli::ShellCommands
- Inherits:
-
Thor
- Object
- Thor
- Retscli::ShellCommands
- Defined in:
- lib/retscli/shell_commands.rb
Class Method Summary collapse
-
.banner(command, namespace = nil, subcommand = false) ⇒ Object
since we are using thor for shell commands we want to remove executable name from command help menu.
- .command_list ⇒ Object
Instance Method Summary collapse
- #capabilities ⇒ Object
- #classes(resource) ⇒ Object
-
#initialize(args, options, config) ⇒ ShellCommands
constructor
A new instance of ShellCommands.
- #metadata ⇒ Object
- #objects(resource) ⇒ Object
- #resources ⇒ Object
- #search_metadata(search) ⇒ Object
- #tables(resource, klass) ⇒ Object
- #timezone_offset ⇒ Object
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, , config) super @display_adapter = config[:display_adapter] end |
Class Method Details
.banner(command, namespace = nil, subcommand = false) ⇒ Object
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.(command, namespace = nil, subcommand = false) super.gsub("#{basename} ", "") end |
.command_list ⇒ Object
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
#capabilities ⇒ Object
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 [:editor] @display_adapter.open_in_editor(@display_adapter.classes(resource), [:editor]) else @display_adapter.page(@display_adapter.classes(resource)) end end |
#metadata ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/retscli/shell_commands.rb', line 74 def if [:editor] @display_adapter.open_in_editor(@display_adapter., [: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 [:editor] @display_adapter.open_in_editor(@display_adapter.objects(resource), [:editor]) else @display_adapter.page(@display_adapter.objects(resource)) end end |
#resources ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/retscli/shell_commands.rb', line 27 def resources if [:editor] @display_adapter.open_in_editor(@display_adapter.resources, [: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) = { :classes => [:classes], :resources => [:resources] } if [:editor] @display_adapter.open_in_editor(@display_adapter.(search, .merge(:color => false)), [:editor]) else @display_adapter.page(@display_adapter.(search, )) 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 [:editor] @display_adapter.open_in_editor(@display_adapter.tables(resource, klass), [:editor]) else @display_adapter.page(@display_adapter.tables(resource, klass)) end end |
#timezone_offset ⇒ Object
66 67 68 |
# File 'lib/retscli/shell_commands.rb', line 66 def timezone_offset puts @display_adapter.timezone_offset end |